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 |
请教各位高手,我的程序不知道哪里错了。。。结果是Runtime error!#include <iostream> #include <algorithm> using namespace std; struct Input { char a[101]; int sum_A; int sum_C; int sum_G; int sum_T; int sum; }; Input c[51]; bool cmp(const Input &d,const Input &h) { if (d.sum < h.sum) { return 1; } else return 0; } int main() { // freopen("in.txt","r",stdin); int n,line; int i,j; cin >> n >> line; for (i = 0; i < line; ++i) //initial { c[i].sum_A = 0; c[i].sum_C = 0; c[i].sum_G = 0; c[i].sum_T = 0; c[i].sum = 0; } for (i = 0; i < line; ++i) { cin >> c[i].a; for (j = n-1; j >= 0; --j) { switch (c[i].a[j]) { case 'A': { ++c[i].sum_A; break; } case 'C': { ++c[i].sum_C; c[i].sum += c[i].sum_A; break; } case 'G': { ++c[i].sum_G; c[i].sum += c[i].sum_A + c[i].sum_C; break; } case 'T': { ++c[i].sum_T; c[i].sum += c[i].sum_A + c[i].sum_C + c[i].sum_G; break; } } } } sort(c,c+line,cmp); for (i = 0; i < line-1; i++) { cout << c[i].a << endl; } cout << c[line-1].a; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator