|
|
вернуться в форумHelp me please with this task! C my code: #include <stdio.h> #include <math.h> #include <string.h> #include <conio.h> int SL (int n) { int q=n/1000, i, s=0; while (q>10) { s+=q%10; q/=10; } s+=q; return s; } int SR (int n) { int s=0,q=n%1000; while (q>10) { s+=q%10; q/=10; } s+=q; return s; } void main() { int S=0,T=0,N; scanf ("%d", &N); if ((SR(N+1)==SL(N+1))||(SR(N-1)==SL(N-1))) printf ("Yes"); else printf ("No"); } Re: Help me please with this task! C Послано prime 6 сен 2016 00:23 I remaked a bit your programm and it got acceped. What you need to change is SL and SR functions: int SL(int n){ int q=n/1000, i, s=0; while(q!=0){ s+=q%10; q/=10; }
return s; } int SR (int n){ int s=0, q=n%1000; while (q!=0) { s+=q%10; q/=10; }
return s; } Thanks for your code, i didn't need to write that myself :) |
|
|