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 xiaoyezi at 2006-06-19 23:02:29 on Problem 1007
#include<iostream.h>
#include<string.h>
int main()
{
	char a[100][50],b[100],c[50];
	int n,m,i,j,count,s,k;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		count=0;
		cin>>a[i];
	 for(j=0;j<n-1;j++)
	 for(k=j+1;k<n;k++)
	 {
         if(a[i][j]>a[i][k])
			 count++;
	 }
	 b[i]=count;
	}
	for(i=0;i<m-1;i++)
	{
		s=b[i+1];
		strcpy(c,a[i+1]);
		j=i;
		while(j>-1&&s<b[j])
		{
			b[j+1]=b[j]; 
            strcpy(a[j+1],a[j]);
			j--;
		}
		b[j+1]=s;
		strcpy(a[j+1],c);
	}
	for(i=0;i<m;i++)
		cout<<a[i]<<endl;
	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