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 CNSpary at 2014-01-01 08:27:09 on Problem 1298
In Reply To:居然还有水题,其实这个位移可以稍稍借用下补码的思想,帖下~ Posted by:1989wd3 at 2012-11-21 22:19:11
> #include<iostream>
> #include<string>
> using namespace std;
> 
> char shift(char x)
> {
>     return (x - 'A' + 21) % 26 + 'A';   //21 = 26 - 5
> }
> 
> int main()
> {
>     string a,b,c;
>     while(cin >> a && a != "ENDOFINPUT")
>     {   
>         string s;
>         cin.ignore(1000,'\n');
>         getline(cin,s);
>         for(int i = 0; i < s.length(); i++)
>         {   
>             if(s[i] - 'A' >= 0 && s[i] - 'A' <= 25) 
>                 s[i] = shift(s[i]);
>         }   
>         cin >> c;
>         for(int i = 0; i < s.length(); i++)
>             cout << s[i];
>         cout << endl;
>     }   
>     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