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

谁帮我看看为什么WA啊!!!急!!!

Posted by dayangou at 2008-07-13 22:28:46 on Problem 1007
#include <iostream>
#include <stdlib.h>
using namespace std;

int cmp ( const void *a , const void *b ) 
{
	return *(int *)a - *(int *)b; 
}

int main()
{
	int i,j,k,row,col,r=-1,m[100]={0};
	char a[100][51],t=0;
	cin>>col>>row;
	for(i=0;i<row;i++)
	{
		for(j=0;j<=col;j++)
		{
			if(j!=col)
				cin>>a[i][j];
			else
				a[i][j]=0;
		}
	}
	for(i=0;i<row;i++)
	{
		for(j=0;j<col;j++)
		{
			for(k=j+1;k<col;k++)
			{
				if(a[i][j]>a[i][k])
				{
					a[i][col]++;
				}
			}
		}
		m[i]=int(a[i][col]);
	}
	for(i=0;i<row;i++)
	{
		for(j=0;j<=col;j++)
		{
			if(j!=col)
				cout<<a[i][j];
			else
				cout<<int(a[i][j]);
		}
		cout<<endl;
	}

	qsort(m,row,sizeof(m[0]),cmp);
//	cout<<m[0]<<m[1]<<m[2]<<endl;

	for(i=0;i<row;i++)
	{
		for(j=0;;j++)
		{
			if( m[i]==int(a[j][col]) )
			{
				t=j;
				break;
			}
		}
		for(k=0;k<col;k++)
		{
			cout<<a[t][k];
		}
		cout<<endl;
		a[j][col]=-1;
	}

	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