J'en ai 9 qui ne valent rien.
Source & formulaire de participation:
http://ymonka.free.fr/maths-et-tiques/i ... u-concours
critor a écrit:Ce sont 5 prototypes TI-Nspire ClickPad non-CAS (bleues), transformés en TI-Nspire CAS.
Contrairement à nLaunch, la transformation est ici différente car spécifique aux prototypes et permanente.
Donc y'a pas écrit TI-Nspire CAS dessus, mais c'est une véritable TI-Nspire CAS dedans et ça le restera.
Ce sera sous papier bulle si j'en ai assez, mais bien évidemment pas sous emballage scellé.
#include <os.h>
#include <libndls.h>
#include <stdint.h>
#include <inttypes.h>
static const unsigned int addr_exdoc_openclass[] = {0x10009B48, 0x10009B20, 0x10009AE8, 0x10009AE8};
#define EXDOC_OPENCLASS ((int(*)(char*, char*, int))nl_osvalue((int*)addr_exdoc_openclass, sizeof(addr_exdoc_openclass)/sizeof(addr_exdoc_openclass[0])))
static const unsigned int hook_addr_newclass[] = {0x10027558, 0x100274C4, 0x10026C54, 0x10026BEC};
#define HOOK_NEWCLASS nl_osvalue((int*)hook_addr_newclass, sizeof(hook_addr_newclass)/sizeof(hook_addr_newclass[0]))
static const unsigned int hook_addr_calc[] = {0x1006CBBC, 0x1006CAEC, 0x1006C2B8, 0x1006C210};
#define HOOK_ADDR_CALC nl_osvalue((int*)hook_addr_calc, sizeof(hook_addr_calc)/sizeof(hook_addr_calc[0]))
extern void* __file_start__;
extern void* __file_end__;
asm(".globl __file_start__ \n"
".globl __file_end__ \n"
"__file_start__: \n"
".incbin \"palprem_class.tns\" \n"
"__file_end__: \n");
uint32_t palprime(uint32_t m)
{
uint32_t n, t, r = 0, c, z = 0;
if(m<=5)
{
const int y[] = {0,2,3,5,7,11};
return y[m];
}
else
{
n = 101-2;
z = 5;
}
while(z<m)
{
printf("%" PRId32 " %" PRId32 "\n",z,n);
while (TRUE)
{
n+=2;
t = n;
/* Calculating reverse of number */
while(t)
{
r *= 10; /* Compound assignment operator r*=10 => r=r*10 */
r += t%10;
t /= 10;
}
/* if reverse equals original then it is palindrome */
if (r == n)
{
/* Checking prime */
if ((n%2 == 0) || (n%3 == 0) || (n%5 == 0))
goto suite;
c = 7;
while( c*c<=n)
{
if ((n%c == 0) || (n%(c+4) == 0))
break;
c+=6;
}
if (c*c>n)
break;
}
suite:
r = 0;
}
z++;
}
return n;
}
HOOK_DEFINE(newclass) {
HOOK_UNINSTALL(HOOK_ADDR_CALC, calc_change);
HOOK_UNINSTALL(HOOK_NEWCLASS , newclass);
HOOK_RESTORE_RETURN(newclass);
}
char resultstring[0x100];
const unsigned char palstring[] = {0x70, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6D, 0x00, 0x28, 0x00};
HOOK_DEFINE(calc_change) {
char* calcul = (char *) HOOK_SAVED_REGS(calc_change)[2];
if( !memcmp( calcul, &palstring, sizeof(palstring) ) )
{
uint32_t input = 0;
int offset = 0;
unsigned char currentn = calcul[sizeof(palstring)];
while( currentn>=0x30 && currentn<=0x39 )
{
input = input*10 + (currentn-0x30);
offset+=2;
currentn = calcul[sizeof(palstring)+offset];
}
if( offset!=0 && calcul[sizeof(palstring)+offset]==')' && calcul[sizeof(palstring)+offset+2]==0)
{
uint32_t result = palprime(input);
char resultstringbuf[0x80];
memset(resultstring , 0x0, 0x100);
memset(resultstringbuf, 0x0, 0x80);
sprintf(resultstringbuf, "%" PRId32 "", result);
int i;
for( i=0; i<0x80; i++ )
{
resultstring[2*i] = resultstringbuf[i];
}
HOOK_SAVED_REGS(calc_change)[2] = (int) resultstring;
} else
{
HOOK_SAVED_REGS(calc_change)[2] = (int) palstring;
}
} else
{
int i;
for( i=0; i<0x100; i++ )
{
if( calcul[2*i]=='p' && !memcmp( calcul+2*i, &palstring, sizeof(palstring)-2 ))
{
HOOK_SAVED_REGS(calc_change)[2] = (int) palstring;
break;
}
}
}
HOOK_RESTORE_RETURN(calc_change);
}
int main()
{
nl_set_resident();
FILE *tns_file;
tns_file = fopen("/logs/palprem.tns","wb");
fwrite (&__file_start__ , sizeof(char) , 4*(&__file_end__-&__file_start__), tns_file );
fclose(tns_file);
EXDOC_OPENCLASS("/logs","palprem.tns",1);
HOOK_INSTALL(HOOK_ADDR_CALC, calc_change);
HOOK_INSTALL(HOOK_NEWCLASS, newclass);
return 0;
}