Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请教各位高手,我的程序不知道哪里错了。。。结果是Runtime error!

Posted by dreamvtkd at 2009-04-21 11:14:16 on Problem 1007
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator