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

用gets()处理数据,输出不是以string的格式,AC了的。各个数据间不要getchar()--这个地方卡了一会。

Posted by xiehe at 2006-04-05 22:09:18 on Problem 2136
都贴没AC的。。。
很多都用字符串做的呀。
我贴个没用字符串做的吧
似乎方便很多


#include <stdio.h>
#include <string.h>
int main()
{
  int a[28];
  char temp[100];
  int i,j,k;
  int mark;
  int blank;
  int maxn=-1;
  memset(a,0,sizeof(a));
  for (i=1;i<=4;i++)
  {
	int t;
	gets(temp);
	for (j=0;j<strlen(temp);j++) 
	{
		t=temp[j]-'A'+1;	
		if (temp[j]>='A' && temp[j]<='Z') 
		{a[t]++;	
		if (a[t]>=maxn) maxn=a[t];
		}
	}
  }
   for (i=maxn;i>0;i--)
   {
	 blank=0;
	 mark=0;
	 for (j=1;j<=26;j++)
	 {
		if (a[j]<i) blank++;
		else
		{
		  for (k=1;k<=2*blank;k++) printf(" ");
		  if (mark==1) printf(" ");
		  printf("*");
		  mark=1;
		  blank=0;
		}	 
	 }
	 printf("\n");
   }
   for (j=1;j<26;j++) printf("%c ",j+'A'-1);
   printf("Z");
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