杭电acm2113
#include <stdio.h> int main() { int n, i, ans, flag=1; while(~scanf("%d", &n)) { ans = 0; while(n) { i = n % 10; if(i%2==0) ans += i; n /= 10; } if(flag) { printf("%d\n", ans); flag = 0; } else printf("\n%d\n", ans); } return 0; }
#include <stdio.h> int main() { int n, i, ans, flag=1; while(~scanf("%d", &n)) { ans = 0; while(n) { i = n % 10; if(i%2==0) ans += i; n /= 10; } if(flag) { printf("%d\n", ans); flag = 0; } else printf("\n%d\n", ans); } return 0; }