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 qf334304146 at 2008-05-12 20:27:59 on Problem 1007
#include<stdio.h>
int main()
{
	int n, m, i, j, k, p, r, q, temp, t, temp1;
	char a[105][55];
	int b[55], c[55];
	scanf("%d%d",&n,&m);
    getchar();
	for(i = 0; i < 55; i++)
	{
        b[i] = 0;
	}
	i = 0;
	p = 0;
	for(j = 0; j < 55; j++)
	{
		c[j] = 0;
	}
	while(m--)
	{
		gets(a[i]);
		for(j = 0; j < n - 1; j++)
		{
			for(k = j + 1; k < n; k++)
			{
				if(a[i][j] > a[i][k])
					b[i]++;
			}
		}
		c[p++] = i;
		i++;
	}
	for(r = 0; r < p; r++)
	{
		t = r;
		for(q = r + 1; q < p; q++)
		{
			if(b[q] < b[t])
				t = q;
		}
        temp = c[r];
		c[r] = c[t];
		c[t] = temp;
		temp1 = b[r];
		b[r] = b[t];
		b[t] = temp1;
	}
	for(r = 0; r < p; r++)
	{
		puts(a[c[r]]);
	}
	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