2020年6月22日 星期一

weekkkkk12

1.練習程設會考題目

區間測速



區間測速-超速之王


CPE-YOU CAN SAY 11

#include <stdio.h>
#include <string.h>
char a[1001];
 int main()
 {
   while(1){
   scanf("%s",a);
   if( strcmp(a,"0")==0 )break;
   int odd=0,even=0;
   for(int i=0;a[i]!=0;i++)
   {
    if(i%2==0) even +=a[i]-'0';
    else odd+=a[i]-'0';
   }
   if( (even-odd)%11!=0 ) printf("%s is not a multiple of 11.\n",a);
   else printf ("%s is a multiple of 11.\n",a);
    }
}

沒有留言:

張貼留言