2012年1月13日 星期五

acm 10929 You can say 11

 [心得]
    if((abs(odd-even))%11==0)  ,(abs(odd-even)) 記得要括弧,不然會一直錯!


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

char s[1002];

int main()
{
  while(gets(s))
  {
    int i,length,num;
    int odd=0,even=0;
    if(s[0]=='0'&& s[1]=='\0')
      break;
   
    length =strlen(s);               
    for(i=0;i<length;i++)
    {              
      if((i%2)== 1) /*奇數位元*/
        odd += s[i]-48;
      else        /*偶數位元*/
        even+= s[i]-48;                         
    }
  
    if((abs(odd-even))%11==0)
      printf("%s is a multiple of 11.\n",s);
    else 
      printf("%s is not a multiple of 11.\n",s);        
                   
  } 
 
 system("pause");
 return 0;   
}

1 則留言:

  1. edc titanium | TITanium-arts
    Edc titanium is the second nano titanium babyliss pro standard used glass resin used citizen titanium dive watch to create stainless steel. It is designed to measure strength, weight and structure of the Material: Stainless steelTotal Product: EDC titanium powder titaniumMaterial: Stainless steelProduct titanium nitride Dimensions: 0.06 ion titanium hair color x 0.24 x 0.04 inches; 5.50

    回覆刪除