|
|
back to boardtell me please whats wrong? main() { long n,sumperv=0,sumposled=0,perv,posled; int flag=0; scanf ("%ld",&n); perv=(n+1)/1000; posled=(n+1)%1000; while (perv) { sumperv+=perv%10; perv/=10; } while (posled) { sumposled+=posled%10; posled/=10; } if (sumperv==sumposled) flag=1; perv=(n-1)/1000; posled=(n-1)%1000; sumperv=0; sumposled=0; while (perv) { sumperv+=perv%10; perv/=10; } while (posled) { sumposled+=posled%10; posled/=10; } if (sumperv==sumposled) flag=1;
if (flag==1) printf ("yes"); else printf ("no");
} Re: tell me please whats wrong? Posted by Sunnat 3 May 2013 15:52 use cin, not scanf() |
|
|