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

Re:400题,附上我的代码

Posted by huangchang9001 at 2012-07-10 21:06:22 on Problem 1677
In Reply To:终于过了!!!附代码!!! Posted by:wocha at 2012-07-10 15:35:58
#include<stdio.h>
#include<string.h>
void main(void){
	int flag[5];
	char name[5][201];
	char wish[201];
	char word[201];
	int h,w,i;
	scanf("%d%d",&h,&w);
	i=0;
	while(i<h) {
		scanf("%s",name[i++]);
		//printf("%s",name[]);
	}
	getchar();
	i=0;
	while(i<w){
		int is_all=1,is_oh=1,is_xi=0;
		int j,k,count;
		j=0;
		while(j<h) flag[j++]=0;
		gets(wish);
		j=0;
		k=0;
		count=0;
		while(1){
			if(wish[j]=='!'||wish[j]==' '||wish[j]=='\0'){
				word[k]='\0';
				if(k>0) {
					count++;
					if(word[0]>='A'&&word[0]<='Z') word[0]+=32;
					k=0;
					while(k<h){
						if(strcmp(name[k],word)==0){
							is_all=0;
							flag[k]=1;
							break;
						}
						k++;
					}
					if(strcmp(word,"beautiful")==0||strcmp(word,"pretty")==0||strcmp(word,"lovely")==0) is_xi=1;
				}
				k=0;
			}
			else word[k++]=wish[j];
			if(wish[j]=='\0') break;
			j++;
		}
		if(count>9)is_oh=0;

		if(is_all) printf("All: ");
		else{
			j=0;
			k=0;
			while(j<5){
				if(flag[j]){
					if(k) printf(" ");
					printf("%s",name[j]);
					k++;
				}
				j++;
			}
			printf(": ");
		}
		if(is_oh) printf("oh\n");
		else if(is_xi) printf("xixi\n");
		else printf("hehe\n");
		i++;
	}
}

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