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

打表附代码

Posted by comzyh at 2013-01-08 16:13:34 on Problem 2538
#include <cstdio>
#include <cstring>
const char dic2[]="       ;    M0,.9 12345678 L -   \\VXSWDFGUHJKNBIO=EARYCQZT'P][";
char str[1000];
int main()
{
	int i,j,l;
	while (gets(str)!=NULL)
	{
		l=strlen(str);
		for (i=0;i<l;i++)
			printf("%c",dic2[str[i]-' ']);
		printf("\n");
	}
}
===================================================================
表生成器兼更容易理解的打表:
#include <cstdio>
#include <cstring>
const char dic[]="  1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
char str[1000];
int main()
{
	int i,j,l,l2=strlen(dic);
	while (gets(str)!=NULL)
	{
		l=strlen(str);
		for (i=0;i<l;i++)
		{
			for (j=1;str[i]!=dic[j] && j<l2;j++);
			if (j<l2)
				printf("%c",dic[j-1]);
			else
				printf(" ");	
		}
		printf("\n");
	}
}

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