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

哪位学长帮忙看一下病根在哪,总不忍心看着小弟含恨而去吧.(c语言)

Posted by 20054959 at 2007-01-15 16:19:21 on Problem 1007
#include<stdio.h>
main()
{char str[100][50];
int n,m,i,j,s[100]={0},p[100]={0},q=0,t,k;
scanf("%d%d",&n,&m);
if(m>0&&m<=100&&n>0&&n<=50)
	{
	for(i=0;i<m;i++)							
		scanf("%s",str[i]);					
	for(i=0;i<m;i++)	                      //计算measure        
		for(j=0;j<n-1;j++)
			for(k=j+1;k<n;k++)
				if(str[i][j]>str[i][k]) 
					p[i]++;	//第i行的measure是p[i]
	for(i=0;i<m;i++)			//(根据p[i]找出measure最小的行,输出并		         {k=10000;			//将其排除在外,然后再循环)
		for(j=0;j<m;j++)
			{if(k>p[j]&&s[j]==0) 
				{t=j;k=p[j];
				 continue;}
			if(k==p[i]&&s[t]==0&&q==0) 
			
				{q=1;
				continue;
				}
			}
		printf("%s\n",str[t]);
		s[t]=1;
		q=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