NOI information through a (C ++ Version) Keep

The first part of the C ++ language

Chapter II array of two-dimensional array

And the third character type array of characters

	本想昨天更博,但被突如其来的摊牌扫了兴致,总算解决了一个麻烦事。

Cryptanalysis

Time limit: 1000 ms Memory Limit: 65536 KB
Submissions: 19243 Number by: 8506

Description [title]
in the information transfer process, in order to prevent information being intercepted, encrypted information often requires a certain way, a simple encryption algorithm, although not enough to completely avoid the intelligence to decipher, but still be able to prevent the information from being easily identified. We give a most simple encryption method, given a string, which by its successor to replace letters from ay, AY letters a to z and A and Z with an alternative, other non-alphabetic characters intact It can be obtained a simple encrypted string.

Input []
input line comprising a string of less than 80 characters.

[Output]
output string encrypted character string in each row.

[Sample input]

Hello! How are you!

[Sample Output]

Ifmmp! Ipx bsf zpv!

I [code]

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[80],b[80];
	gets(a);
	for(int i=0;a[i]!='\0';i++)
	{
		if((a[i]>=97&&a[i]<=121)||(a[i]>=65&&a[i]<=89))b[i]=a[i]+1;
		else 
		{
			if(a[i]==122||a[i]==90)b[i]=a[i]-25;
				else b[i]=a[i];
		}
	}
	for(int i=0;a[i]!='\0';i++)
	cout<<b[i];
	return 0;
}

Note: ASCII code can not be wrong

Encrypted medical history form

Time limit: 1000 ms Memory Limit: 65536 KB
Submissions: 14033 Number by: 7236

Description [title]
Little Britain is a pharmacy junior, got the opportunity to go to the hospital pharmacy internship during the summer.
During and after the pharmacy practice, Xiaoying solid foundation of professional doctors won praise, that the small British had achieved good results in the introduction to computing, the additional director and gave her the task of decrypting the encrypted during the war, some the list of the wounded.
After the study, the following was found Little Britain encryption law (in brackets is a - examples of the "original> ciphertext") of
1. The text characters are all rotated to the left of the three positions (dec alphabet -> ABZ )
2. reverse storage (ABCD -> DCBA)
3. reverse case (abXY -> ABxy)

[In]
an encrypted string. (Length less than 50 and contains only lowercase letters)

[] Output
string output decryption.

[Sample input]

GSOOWFASOq

[Sample Output]

Trvdizrrvj

I [code]

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[50],b[50];
	gets(a);
	for(int i=0;i<strlen(a);i++)
	{   if(a[i]=='z')b[i]='c';
			else if(a[i]=='y')b[i]='b';
					else if(a[i]=='x')b[i]='a';
							else if(a[i]=='Z')b[i]='C';
								else if(a[i]=='Y')b[i]='B';
									else if(a[i]=='X')b[i]='A';
										else b[i]=a[i]+3;
	}
	for(int i=0;i<strlen(a);i++)
	{
	if(b[i]>=97&&b[i]<=122)b[i]-=32;
	else b[i]+=32;
	}
	for(int i=strlen(a)-1;i>=0;i--)
	cout<<b[i];
	return 0;
}

Note: capitalization distinction not forget!

Finishing name of the drug

Time limit: 1000 ms Memory Limit: 65536 KB
Submissions: 13977 Number by: 6826

[Title] Description
doctors often pay no attention to the case when writing the name of the drug, the format is a bit confusing. Now it asks you to write a program that will sort out the confusion of the doctor writing the name of the drug into a standardized format, that is, the first character of the name of the drug if it is to be a capital letter, other letters in lower case. As will ASPIRIN, aspirin organized into Aspirin.

[Enter]
The first line of a number n, there are n represents the name of the drug you want to organize, n does not exceed 100.
Next n lines of a word, no longer than 20 indicate drugs doctors handwritten. Drug names of letters, numbers and - Composition.

[Output]
n lines, each word corresponding to the input specification written drug name.

[Sample input]

4
AspiRin
cisapride
2-PENICILLIN
Cefradine-6

[Sample Output]

Aspirin
Cisapride
2-penicillin
Cefradine-6

I [code]


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char a[100][20];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
	if(a[i][0]>=97&&a[i][0]<=122)a[i][0]-=32;
	for(int j=1;j<strlen(a[i]);j++)
		if(a[i][j]>=65&&a[i][j]<=90)a[i][j]+=32;
	}
   	for(int i=0;i<n;i++)
	cout<<a[i]<<endl;
	return 0;
}

Pain, still can not find myself how can this code problem, the sample is too, had not submitted a test point is not right, o (╥﹏╥) o.

Released four original articles · won praise 4 · Views 1523

Guess you like

Origin blog.csdn.net/Catherine_he_ye/article/details/104340555