|
|
вернуться в форумcan someone help me? plzzz #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> int p[20]; using namespace std; int main() { int a; int i,j,x,y,c; cin>>a; for(i=0; i<a; i++) cin>>p[i];
for (i=0; i<a; i++) for (j=i+1; j<a; j++) if (p[i]<p[j]) { c=p[j]; p[j]=p[i]; p[i]=c; }
if (a==1) cout<<p[0]; else if (a==2) cout<<abs(p[0]-p[1]); else x=p[0]; y=p[1]; for (i=2; i<a; i++) { if (x>y) y=y+p[i]; else x=x+p[i]; }
if(a>2) cout<<abs(x-y);
} what i have wrong? it sad "wrong answer" |
|
|