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

刚学习编程,总是过不了,出问题了,求指教

Posted by chunjingshui at 2013-04-25 16:42:38 on Problem 1007
#include<iostream>
using namespace std;
int main()
{
	int len=0,m,n,middata2;
	char middata1;
	int a[100][50];
	char mid[100];
	int mid2[100];
	cin>>n>>m;
	for(int i=0;i<m;i++)//输入
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	for(int i1=0;i1<m;i1++)//计算权值
	{   
		len=0;
		for(int j=0;j<n;j++)
			for(int k=j+1;k<n;k++)
			{
				if(a[i1][j]>a[i1][k])
					len++;    
			}
		mid[i1]=len;	
		mid2[i1]=i1;
	}
	for(int i2=0;i2<m-1;i2++)//对比mid[]
		for(int j=0;j<m-i2-1;j++)
		{
			if(mid[j]<mid[j+1])
			{
				middata1=mid[j];
				mid[j]=mid[j+1];
                mid[j+1]=middata1;

				middata2=mid2[j];
				mid2[j]=mid2[j+1];
                mid2[j+1]=middata2;
			}
		}
	for(int i3=0;i3<m;i3++)//利用mid2导出数组的行
	{
		int h;
		h=mid2[i3];
		for(int j=0;j<n;j++)
		cout<<a[h][j];
		cout<<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