0 of 3 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 3 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 16 17 18 19 20 21 22 23 |
#include<iostream> using namespace std; bool prime_number(int a){ int i; for (i = 2; i < a; ++i) { if(a%i==0)break; } if(i==a)return true; return false; } int main(){ int n; bool empty=1; cout<<"please input a number:"; cin>>n; for (int i = 2; i <n-2 ; ++i) { if(prime_number(i)&&prime_number(i+2)){ cout<<i<<" "<<i+2<<endl; empty=0; } } if(empty)cout<<"empty"; } |
输入13,程序输出结果为 和
提示:答案是两组数,数之间是一个空格。
2、阅读程序,填写结果: (2010年真题)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <iostream> using namespace std; int rSum(int j){ int sum = 0; while (j != 0) { sum = sum * 10 + (j % 10); j = j / 10; } return sum; } int main(){ int n, m, i; cin>>n>>m; for (i = n; i < m; i++) if (i == rSum(i)) cout<<i<<' '; return 0; } |
输入为90 120,输出结果为
3、阅读程序,输出结果。 (2011年提高组)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include<iostream> using namespace std; int n; void f2(int x,int y); void f1(int x,int y){ if(x<n) f2(y,x+y); } void f2(int x,int y){ cout<<x<<' '; f1(y,x+y); } int main(){ cin>>n; f1(0,1); return 0; } |
输入:30
输出: