File tree Expand file tree Collapse file tree 9 files changed +34
-95
lines changed Expand file tree Collapse file tree 9 files changed +34
-95
lines changed Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
3-
43using namespace std ;
5-
64int main () {
75 string str;
86 while (getline (cin,str)) {
97 for (int i=0 ; i<str.size (); i++) {
10- char temp=str[i];
11- if (str[i]==' z' ) {
12- str[i]=' a' ;
13- } else if (str[i]==' Z' ) {
14- str[i]=' A' ;
15- } else if ((str[i]<=' Z' &&str[i]>=' A' )||(str[i]<=' z' &&str[i]>=' a' )) {
8+ if (str[i]==' z' ||str[i]==' Z' ) {
9+ str[i]-=25 ;
10+ } else if ((str[i]>=' a' &&str[i]<=' y' )||(str[i]>=' A' &&str[i]<=' Y' )) {
1611 str[i]+=1 ;
1712 } else {
1813 continue ;
1914 }
2015 }
21- cout<<str;
16+ cout<<str<<endl ;
2217 }
2318 return 0 ;
2419}
Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
3-
43using namespace std ;
5-
64int main () {
75 string str;
86 while (getline (cin,str)) {
@@ -13,6 +11,8 @@ int main() {
1311 for (int i=0 ; i<str.size (); i++) {
1412 if (str[i]>=' A' &&str[i]<=' Z' ) {
1513 str[i]=(str[i]-' A' -5 +26 )%26 +' A' ;
14+ } else {
15+ continue ;
1616 }
1717 }
1818 cout<<str<<endl;
Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
3-
43using namespace std ;
5-
64int main () {
75 string str1,str2;
8- int num[200 ]= {0 };
96 while (getline (cin,str1)) {
10- if (str1==" #" ) {
11- break ;
12- }
7+ if (str1==" #" )break ;
138 getline (cin,str2);
14- for (int i=0 ; i<str2.size (); i++) {
15- num[str2[i]]++;
9+ int num[200 ]={0 };
10+ for (int i=0 ;i<str2.size ();i++){
11+ num[str2[i]]++;
1612 }
17- for (int i=0 ; i<str1.size (); i++) {
13+ for (int i=0 ;i<str1.size ();i++){
1814 printf (" %c %d\n " ,str1[i],num[str1[i]]);
1915 }
2016 }
Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
3-
43using namespace std ;
5-
6- int main (){
4+ int main () {
75 string str;
8- int num[26 ]={0 };
9- while (cin>>str){
10- for (int i=0 ;i<str.size ();i++){
6+ int num[26 ]= {0 };
7+ while (cin>>str) {
8+ for (int i=0 ; i<str.size (); i++) {
119 num[str[i]-' A' ]++;
1210 }
13- for (int i=0 ;i<26 ;i++){
11+ for (int i=0 ; i<26 ; i++) {
1412 printf (" %c:%d\n " ,i+' A' ,num[i]);
1513 }
1614 }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ long int skew(string num) {
1919
2020int main () {
2121 string str;
22- while (cin>>str){
22+ while (cin>>str) {
2323 cout<<skew (str)<<endl;
2424 }
2525 return 0 ;
Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
3-
43using namespace std ;
5-
64int main () {
75 string str1,str2,str3;
86 while (getline (cin,str1)) {
@@ -11,6 +9,7 @@ int main() {
119 string temp=" " ;
1210 for (int i=0 ; i<str1.size (); i++) {
1311 if (str1[i]==' ' ||i==str1.size ()-1 ) {
12+ // 如果是最后一个字符,加上
1413 if (i==str1.size ()-1 ) {
1514 temp+=str1[str1.size ()-1 ];
1615 }
Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
3-
43using namespace std ;
5-
64// 是否是小写字母
7- bool ischar (char x){
8- if (x>=' a' &&x<=' z' ){
5+ bool ischar (char x) {
6+ if (x>=' a' &&x<=' z' ) {
97 return true ;
108 }
119 return false ;
@@ -14,11 +12,11 @@ bool ischar(char x){
1412int main () {
1513 string str;
1614 while (getline (cin,str)) {
17- if (ischar (str[0 ])){
18- cout<<(char )(str[0 ]-' a' +' A' );
19- } else {
20- cout<<(char )str[0 ];
21- }
15+ if (ischar (str[0 ])) {
16+ cout<<(char )(str[0 ]-' a' +' A' );
17+ } else {
18+ cout<<(char )str[0 ];
19+ }
2220
2321 bool isblank=false ;// 空白符分隔标记
2422 for (int i=1 ; i<str.size (); i++) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11#include < iostream>
22#include < string>
33#include < algorithm>
4-
54using namespace std ;
6-
75int main () {
86 string str;
9- cin>>str;
10- string sstr[str.size ()];
11- for (int i=0 ; i<str.size (); i++) {
12- sstr[i]=str.substr (i,str.size ());
13- }
14- sort (sstr,sstr+str.size ());
15- for (int i=0 ; i<str.size (); i++) {
16- cout<<sstr[i]<<endl;
7+ while (getline (cin,str)) {
8+ string sstr[str.size ()];
9+ for (int i=0 ; i<str.size (); i++) {
10+ sstr[i]=str.substr (i,str.size ());
11+ }
12+ sort (sstr,sstr+str.size ());
13+ for (int i=0 ; i<str.size (); i++) {
14+ cout<<sstr[i]<<endl;
15+ }
1716 }
1817 return 0 ;
1918}
You can’t perform that action at this time.
0 commit comments