Skip to content

Commit

Permalink
Onze eh soma de impares menos soma de pares mod 11
Browse files Browse the repository at this point in the history
  • Loading branch information
philss committed Dec 5, 2011
1 parent 32fc812 commit 6e4d668
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions onze/onze.c
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <string.h>

int main(int argc, const char *argv[])
{
char number[1001];
int i = 0, size = 0, even = 1, total = 0;
while ( scanf("%s\n",number) != EOF && strcmp(number,"0\0") ) {
size = strlen(number);
for (i=0; i < size; i++) {
total = (even ? total + (number[i] - 48) : total - (number[i] - 48));
even = ( even ? 0 : 1);
}
printf("%s is%s a multiple of 11.\n",number, ( ( total % 11 == 0 ) ? "" : " not" ) );
total = 0;
even = 1;
size = 0;
}
return 0;
}
7 changes: 7 additions & 0 deletions onze/values.txt
@@ -0,0 +1,7 @@
112233
30800
2937
323455693
5038297
112234
0

0 comments on commit 6e4d668

Please sign in to comment.