hdu1048 (c + +)

Source: Internet
Author: User

It is convenient to deal with this problem by string string.

#include <iostream>
#include <string>
using namespace Std;
String cipher (string &s); Referred to as a parameter, this function returns the string of a string class
int main ()
{
String s1, S2, S3,S4;
while (1)
{
Getline (CIN, S1);
if (S1 = = "Endofinput")
Break
Getline (CIN, S2);
Getline (CIN, S3);
S4 = cipher (S2);
cout <<s4<< Endl;
}
return 0;
}
String cipher (String &s)
{
Char *p = new Char[s.size () + 1];//set dynamic character array
P[s.size ()] = 0; Sets the last element of the array to 0, which is the null character, the end flag
int i;
for (i = 0; i < s.size (); i++)
{
if (S[i] <= ' E ' &&s[i] >= ' A ')
P[i] = s[i] + 21;
else if (' E ' < s[i] && s[i] <= ' Z ')
P[i] = s[i]-5;
Else
P[i] = s[i];
}
String S1 (p); Integer assignment
Delete[]p;
return s1;
}

hdu1048 (c + +)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.