| ||||||||||
| 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问题,谁能解释下RE问题是什么原因,附代码#include<iostream>
using namespace std;
int count_inver(char *str, int len)
{
int i;
int cnt = 0;
int a[4] = {0};
for(i = len - 1; i >= 0; i--) {
switch (str[i]) {
case 'A':
a[1]++;
a[2]++;
a[3]++;
break;
case 'C':
a[2]++;
a[3]++;
cnt += a[1];
break;
case 'G':
a[3]++;
cnt += a[2];
break;
case 'T':
cnt += a[3];
}
}
return cnt;
}
void sort(int b[],int c[],int num){//从小到大排列,排列的顺序结果存到数组c中
int m=1000,k=0,t=0,i,j;
int q=0,n;
for(j=0;j<num;j++)
{ for(i=j;i<num;i++)
{
if(m>b[i])
{ m=b[i];k=i;}
}
b[k]=b[j];
b[j]=m;//交换数据
n=c[j];//交换下标
c[j]=c[k];
c[k]=n;
m=1000;
}
}
int main(){
int lenth,num,i=0,j=0;
char a[50][50]={0};
int counter[50]={-1};
int c[50];
for(int k=0;k<50;k++){
c[k]=k;
}
cin>>lenth>>num;
i=0;j=0;
while(i<num){
while(j<lenth)
{cin>>a[i][j];j++;}
counter[i]=count_inver(&a[i][0],lenth);
j=0;
i++;
}
sort(counter,c,num);
for(i=0;i<num;i++){
for(j=0;j<lenth;j++)
{ cout<<a[c[i]][j];
}
cout<<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