Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:为什么老是wa,求大牛In Reply To:为什么老是wa,求大牛 Posted by:shoukaizhe at 2011-07-04 22:26:19 > #include<iostream> > #include<string.h> > > using namespace std; > > int main() > { > int n,m=0; > cin>>n>>m; > char c[100][100]; > int *a = new int[m]; > > > > for(int cou1 = 0; cou1<m; cou1++) > { > cin>>c[cou1]; > for(int cou2 =0; cou2<n; cou2++) > { > for(int j = 1; j <= n-cou2-1; j++) > if(c[cou1][cou2] > c[cou1][cou2+j])a[cou1]++; > } > } > > int t; > char *temp = new char[n+1]; > > for(int k = 0; k < m; k ++) > { > for(int l = 0; l < m-k; l++) > { > if(a[l] > a[l+1]) > { > t = a[l]; > a[l] = a[l+1]; > a[l+1] = t; > strcpy(temp, c[l]); > strcpy(c[l], c[l+1]); > strcpy(c[l+1], temp); > } > } > } > cout<<endl; > for(int k = 0; k < m; k ++) > cout<<c[k]<<endl; > > return 0; > > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator