Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main () {
  5.     int i,sP,sI,aux,vetor[1000];
  6.     char num[1001];
  7.  
  8.     for ( ; ; ) {
  9.         memset (num,0,sizeof(char)*1001);
  10.         memset (vetor,0,sizeof(int)*1000);
  11.         scanf("%s",num);
  12.         if ( num[0] == '0' )
  13.             break;
  14.         aux = strlen(num);
  15.         for ( i = 0 ; i < aux; i++ ){
  16.             vetor[i]=num[i]-48;
  17.         }
  18.        
  19.         sP=0,sI=0;
  20.         for ( i = 0 ; i < aux ;i++ ) {
  21.             if ( i%2 == 0 )
  22.                 sP += vetor[i];
  23.             else
  24.                 sI += vetor[i];
  25.         }
  26.         if ( sP == sI || (sI-sP)%11 == 0 )
  27.             printf("%s is a multiple of 11.\n",num);
  28.         else
  29.             printf("%s is not a multiple of 11.\n",num);
  30.         }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement