E
ethanmys
hello everyone. hours ago i found a topic about solving the problem:
find out 2 int between certain rang, say 1---100, both the 2 int's sum
and minus should be a int's square.
i write this piece of code and i want you to give some advice. can the
code run quicker? i think there must exist many quicker ones.
/*
this doucument and source code belong to Ethan Mys, oct 30, 2005.
any modification to improve the source code is welcome.
you can also spit at this piece of "shit", because i am a masochist.
E-Mail: (e-mail address removed)
*/
#include<stdio.h>
int main()
{
int k=0;
int tb[][6]={{1,9,25,81,121,169},\
{4,16,36,64,100,144,}};
for(k=1;k<=13;k++)
{
int k2=k*k;
int temp=0;int temp2=0;
while((temp2=tb[k%2?0:1][temp])<k2)
{
int res[10];
res[temp]=(k2+temp2)/2;
printf("%3d and %3d ",res[temp],k2-res[temp]);
temp++;
}
printf("\n");
}
getchar();
}
find out 2 int between certain rang, say 1---100, both the 2 int's sum
and minus should be a int's square.
i write this piece of code and i want you to give some advice. can the
code run quicker? i think there must exist many quicker ones.
/*
this doucument and source code belong to Ethan Mys, oct 30, 2005.
any modification to improve the source code is welcome.
you can also spit at this piece of "shit", because i am a masochist.
E-Mail: (e-mail address removed)
*/
#include<stdio.h>
int main()
{
int k=0;
int tb[][6]={{1,9,25,81,121,169},\
{4,16,36,64,100,144,}};
for(k=1;k<=13;k++)
{
int k2=k*k;
int temp=0;int temp2=0;
while((temp2=tb[k%2?0:1][temp])<k2)
{
int res[10];
res[temp]=(k2+temp2)/2;
printf("%3d and %3d ",res[temp],k2-res[temp]);
temp++;
}
printf("\n");
}
getchar();
}