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:why Presentation Error?

Posted by shunan at 2005-09-09 13:30:38 on Problem 2141
In Reply To:Re:why Presentation Error? Posted by:xiaoha at 2005-09-08 17:36:15
这是我的代码,麻烦看一下输出格式那里有错?我崩溃了!thx!!!
#include<stdio.h>
#include<string.h>
char key[27],tran[81],tranto[81];
int main()
{
	int i,count=0,len;
	scanf("%s",key);
	while(1==scanf("%s",tran))
	{
		count++;
		len=strlen(tran);
		for(i=0;i<len;i++)
		{
			if(tran[i]>90)
			{
				tranto[i]=key[tran[i]-97];
			}
			else
			{
				tranto[i]=key[tran[i]-65];
				tranto[i]-=32;
			}
		}
		tranto[len]=0;
		if(count==1)
		{
			printf("%s",tranto);
		}
		else
		{
			printf(" %s",tranto);
		}
	}
	printf("\n");//°把这行去了,还是PE!啊
	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