0 of 5 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 5 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、阅读程序,根据输入,写出输出结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <iostream> #include <string> using namespace std; int main() { string s; getline(cin,s); int c=0; for(int i=0;i<s.size();i++){ if('a'<=s[i]&&s[i]<='z') s[i]=s[i]-97+65; } cout<<s<<endl; return 0; } |
2、阅读程序写结果:(2014年普及组)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <iostream> #include <string> using namespace std; int main() { string st; int i, len; getline( cin, st ); len = st.size(); for ( i = 0; i < len; i++ ) if ( st[i] >= 'a' && st[i] <= 'z' ) st[i] = st[i] - 'a' + 'A'; cout << st << endl; return(0); } |
输入:Hello, my name is Lostmonkey.
输出:
3、阅读程序写结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include <iostream> #include <string> using namespace std; int main() { string s; char m1, m2; int i; getline(cin, s); m1 = ' '; m2 = ' '; for (i = 0; i < s.length(); i++) if (s[i] > m1) { m2 = m1; m1 = s[i]; } else if (s[i] > m2) m2 = s[i]; cout<<(m1)<<' '<<(m2)<<endl; return 0; } |
输入:Expo 2010 Shanghai China 输出:
提示:字符对应ASCII码 空格=32 ‘0’=48 ‘A’=65 ‘a’=97
4、阅读程序写结果: (2014年普及组)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <iostream> using namespace std; const int SIZE = 100; int main() { int p[SIZE]; int n, tot, i, cn; tot = 0; cin >> n; for ( i = 1; i <= n; i++ ) p[i] = 1; for ( i = 2; i <= n; i++ ) { if ( p[i] == 1 ) tot++; cn = i * 2; while ( cn <= n ) { p[cn] = 0; cn += i; } } cout << tot << endl; return(0); } |
输入:30
输出:
5、阅读程序写结果。(2011年普及组)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include<iostream> #include<string> using namespace std; int main() { string map= "2223334445556667778889999"; string tel; int i; cin>>tel; for(i=0;i<tel.length();i++) if((tel[i]>='0') && (tel[i]<='9') ) cout<<tel[i]; else if( (tel[i]>='A') && (tel[i]<='Z')) cout<<map[tel[i]-'A']; cout<<endl; return 0; } |
输入:CCF-NOIP-2011 输出为: