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:通过了!为什么把宏定义的#define N 50 改为#define N 51 就对了呢?In Reply To:通过了!为什么把宏定义的#define N 50 改为#define N 51 就对了呢? Posted by:jean890915 at 2011-10-04 20:36:17 > #include "iostream" > using namespace std; > > #define N 51 %我修改的地方!!! > #define M 101 > > int DNA_inv(char a[],int m) > { > int i,j,sum=0; > for (i=0;i<m-1;i++) > { > for (j=i+1;j<m;j++) > { > if (a[i]>a[j]) > sum++; > } > } > return sum; > } > > typedef struct node > { > int x; > int y; > }my_struct; > > void insert_sort(my_struct a[],int m) > { > int i,j; > for(i=2;i<=m;i++) > { > a[0] = a[i]; > j = i-1; > while (a[0].y<a[j].y) > a[j+1] =a[j--]; > a[j+1] = a[0]; > } > } > > void DNA(void) > { > int m,n,i; > char str[M][N]; > my_struct b[M]; > cin>>m>>n; > for (i=1;i<=n;i++) > { > cin>>str[i]; > b[i].x = i; > b[i].y = DNA_inv(str[i],m); > } > insert_sort(b,n); > for (i=1;i<=n;i++) > { > cout<<str[b[i].x]<<endl; > } > } > > int main(void) > { > DNA(); > return 0; > } > > > 终于通过了,内牛满面啊! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator