关于while(cin>>ch)的利用

P1914 小书童——凯撒密码

TURN0927 @ 2019-09-23 22:50:19

include <iostream>

int main() { using namespace std; int n; char ch; cin >> n; while(cin >> ch) { if(ch+n>=97&&ch+n<=122){ cout << char(ch+n); }else{ cout << char(ch+n-26); } } return 0;
}


by Belarus @ 2019-09-23 22:53:58

include <bits/stdc++.h>
int main() { 
    using namespace std; 
    int n; char ch; 
    cin >> n;
    while(cin >> ch) { 
        if(ch+n>=97&&ch+n<=122){ 
           cout << char(ch+n); 
        }
        else{ cout << char(ch+n-26); } 
  } 
  return 0;
}

by su226 @ 2019-09-23 23:07:17

希望更丰富的展现?使用Markdown


by CCTV5 @ 2019-09-23 23:32:58

希望更丰富的展现?使用Markdown


|