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 stupidcccc at 2009-08-01 00:51:05 on Problem 1056
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

struct code{
	char seq[11];
	int len;};

int main()
{
	int i,j,count,min,flag,n;
	code ary[8];
	n=0;
	//while( ( scanf("%s",ary[0].seq) )!=EOF )
	while(cin>>ary[0].seq)
	{
		ary[0].len=strlen(ary[0].seq);
		flag=1;
		n++;
		count=0;
		do{
			count++;
			scanf("%s",ary[count].seq);
			ary[count].len=strlen(ary[count].seq);
		}while(ary[count].seq[0]!='9');
		
		for(i=0;i<count-1 && flag!=0;i++)
			for(j=i+1;j<count && flag!=0;j++)
			{
				if(ary[i].len<=ary[j].len)
					min=ary[i].len;
				else min=ary[j].len;
				flag=strncmp(ary[i].seq,ary[j].seq,min);
			}
		if(flag==0)
			printf("Set %d is not immediately decodable\n",n);
		else printf("Set %d is immediately decodable\n",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