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
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

Why PE? Please help!!!

Posted by milesliu at 2009-08-25 13:47:05 on Problem 2245
#include <stdio.h>
char a[12];
int n;
char r[6];

void sort()
{
	char x,m;
	char i,j;
	for(i=0;i<n-1;i++)
	{
		m=i;
		for(j=i+1;j<n;j++)
		{
			if(a[j]<a[m])
			{
				m=j;
			}
		}
		x=a[i];
		a[i]=a[m];
		a[m]=x;
	}
}

void dg(int step, int k)
{
	int i;
	if(step>5)
	{
		printf("\n");
		for(i=0;i<5;i++)
		{
			printf("%d ",r[i]);
		}
		printf("%d",r[i]);
	}
	else
	{
		for(i=k;i<n;i++)
		{
			r[step]=a[i];
			dg(step+1,i+1);
		}
	}
}

int main()
{
    int i;
	printf("\n");
    scanf("%d", &n);
    while(n>0)
    {
        for(i=0;i<n;i++)
		{
			scanf("%d",&(a[i]));
		}
		sort();
		dg(0,0);
		scanf("%d", &n);
		if(n) 
		  printf("\n");
    }
	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