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 <string> #include <stdlib.h> #define NUM 15 #define LENGTH 10 using namespace std; struct DNA { char str[LENGTH]; int measure; }; int cmp(const void *a,const void *b) { return((*(struct DNA *)a).measure-(*(struct DNA *)b).measure>0)?1:-1; } int main() { struct DNA dna[NUM]; int n,m; // char *ptr; cin>>n>>m; for(int i=0;i<m;i++) { cin>>dna[i].str; dna[i].measure=0; // ptr=(char *)dna[i].str; for(int j=0;j<n-1;j++) { for(int ii=j+1;ii<n;ii++) if(dna[i].str[j]=='A') break; else if(dna[i].str[j]>dna[i].str[ii]) dna[i].measure++; // ptr++; } } qsort(dna,m,sizeof(DNA),cmp); for(int i=0;i<m;i++) cout<<dna[i].str<<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