求分析

#include <stdio.h>

#include <string.h>

#include <math.h>

int main()

{

int i,length,num=0,n=0;

char s[102];

while(1)

{

gets(s);

if(s[0]=='0')

break;

length = strlen(s);

for(i=0;i<length;i++)

{

num += (s[i]-'0')*(int)pow(10,length-1-i); //注意pow返回值类型为double

}

num = num/10-num%10*5;

if(0 == num%17)

printf("1\n");

else

printf("0\n");

num = 0;

}

return 0;

}

...全文
111 4 打赏 收藏 举报

4 条回复

• 打赏
• 举报

• 打赏
• 举报

• 打赏
• 举报

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX_NUM     10

int main(void)
{

#if 1
unsigned long long num, diff;
int cnt = 0, s_digit;

while (1 == scanf("%llu", &num) && num > 0) {
if (cnt++ > MAX_NUM)
break;
s_digit = num % 10;
diff = llabs(num / 10 - s_digit * 5);

if (diff % 17 == 0)
printf("1\n");
else
printf("0\n");

}
#else
int i,length,num=0,n=0;

char s[102];

while(1)
{

gets(s);

if(s[0]=='0')

break;

length = strlen(s);

for(i=0;i<length;i++)

{

num += (s[i]-'0')*(int)pow(10,length-1-i); //注意pow返回值类型为double

}

num = num/10-num%10*5;

if(0 == num%17)

printf("1\n");

else

printf("0\n");

num = 0;

}
#endif
return 0;

}

• 打赏
• 举报

C语言

6.6w+

C语言相关问题讨论

2017-11-05 08:21