noip2012 阅读程序一


noip2012 阅读程序1

  #include<cstdio> #include<cstring> #include<math.h> #include<stdlib.h> #include<algorithm> #include<ctime> #include<iostream> using namespace std; const int maxn=1000; int n,i,temp,sum,a[100]; int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int i,j; cin$amp;>amp;$gt;n; for(i=1;i<=n;i++) cin$amp;>amp;$gt;a[i]; for(i=1;i<=n-1;i++) if(a[i]>a[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; } for(i=n;i>=2;i--) if(a[i]<a[i-1]) { temp=a[i]; a[i]=a[i-1]; a[i-1]=temp; } sum=0; for(i=2;i<=n-1;i++) sum+=a[i]; cout$amp; <amp> </amp> <amp> </amp>



java 程序开发 Java基础知识

淡定的蛋痛 12 years, 2 months ago

Your Answer