4.26

 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 int main()
 5 {
 6     int  a[5]={},b;
 7     cout<<"请输入5个元素"<<endl;
 8     for(b=0;b<5;b++)
 9     {
10         cin>>a[b];
11         cout<<a[b]<<" ";
12     }
13     return 0;
14 }
 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int zimushu(char *str);
 8     char str[100];
 9     cout<<"输入一个英文句子:";
10     gets(str);
11     cout<<zimushu(str);
12 }
13 int zimushu(char *str)
14 {
15     int n=0,i;
16     for(i=0;str[i];i++)
17     {
18         if(str[i]>='a'&&str[i]<=n++);
19     
20     
21     }
22 
23     return n;
24 
25 
26 
27 
28 
29 }
 1 #include <iostream>
 2 #include <String>
 3 using namespace std;
 4 void reverse(string& s)
 5 {
 6     int l = s.length();
 7     for(int i = 0; i < (s.length() + 1) / 2; i++)
 8     {
 9         char a;
10         a = s[l - i - 1];
11         s[l - i - 1] = s[i];
12         s[i] = a;
13     }
14     cout << s;
15 }
16 int main()
17 {
18     string s1;
19     cout << "请输入一串字符串" << endl;
20     cin >> s1;
21     reverse(s1);
22     cout << endl;
23     return 0;
24 }

 

posted @ 2023-04-26 22:45  Code13  阅读(73)  评论(0编辑  收藏  举报