0 of 2 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 2 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)
25、阅读程序写出结果:
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 main() { int len,maxlen; string s,ss; maxlen=0; do { cin>>ss; len=ss.length(); if(ss[0]=='#')break; if(len>maxlen) { s=ss; maxlen=len; } }while(true); cout<<s<<endl; return 0; } |
输入:
I
am
a
citizen
of
China
#
输出为:
26、阅读程序写结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include <iostream> using namespace std; int fun(int n,int fromPos,int toPos) { int t,tot; if(n==0)return 0; for(t=1;t<=3;t++) if(t!=fromPos && t != toPos)break; tot=0; tot+=fun(n-1,fromPos,t); tot++; tot+=fun(n-1,t,toPos); return tot; } int main() { int n; cin>>n; cout<<fun(n,1,3)<<endl; return 0; } |
输入:5
输出: