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:请教各位这个程序那里错了??

Posted by zjl at 2005-02-27 23:23:25 on Problem 2136
In Reply To:请教各位这个程序那里错了?? Posted by:zjl at 2005-02-27 23:23:14
# include <iostream.h>
# include <string.h>

# define MAX 72
# define NUM 26


void main(){
	char c[MAX];
	int i,a[NUM],j;
	for(i=0;i<NUM;i++)
		a[i] = 0;
	for(i=0;i<4;i++){
		cin.getline(c,MAX);
		for(j = 0;j<MAX;j++){
			if(c[j]>='A'&&c[j]<='Z')
				a[c[j]-'A']++;
			}
		memset(c,0,sizeof(c));
	}
	int nmax = a[0];
	for(i=0;i<NUM-1;i++){
		if(nmax<a[i+1])
		nmax=a[i+1];
	}
	for(i=0;i<nmax;i++){
		for(j=0;j<NUM-1;j++){
			if(a[j]>=(nmax-i))
				cout<<"* ";
			else
				cout<<"  ";
		}
		if(a[NUM-1]>=(nmax-i))
			cout<<"*";
		else
		    cout<<" ";
		cout<<endl;
	}
	cout<<"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"<<endl;

}

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