1.
a) int x; cint >>x;
b) int y; cint >>y;
c) int i=1;
d) int power=1;
e) power = power * x;
f) i++;
g) if ( i<=y)
h) cout << power;
2.
a) 情况1输出
*****
$$$$$
情况2输出
$$$$$
b)
情况1输出
*****
情况2输出
#####
$$$$$
3.
a)
if ( y == 8 )
if ( x == 5 )
{
cout << “#####” << endl;
cout << “$$$$$” << endl;
cout << “&&&&&” << endl;
}
else
cout << “@@@@@” << endl;
b) 假定x=5,y=8,产生的输出如下所示。
if ( y == 8 )
if ( x == 5 )
cout << “@@@@@” << endl;
else
{
cout << “#####” << endl;
cout << “$$$$$” << endl;
cout << “&&&&&” << endl;
}
c)
if ( y == 8 )
{
if ( x == 5 )
cout << “@@@@@” << endl;
else
{
cout << “#####” << endl;
cout << “$$$$$” << endl;
}
cout << “&&&&&” << endl;
}
d)
if ( y == 8 )
{
cout << “#####” << endl;
}
else
{
if ( x == 5 )
cout << “@@@@@” << endl;
else
cout << “$$$$$” << endl;
cout << “&&&&&” << endl;
}
4. 编程
#include
main()
{
int score;
cin << score;
if (score >=90)
cout << “优秀”;
else if (score>=80)
cout <<“良好”;
else if (score>=70)
cout <<“中等”;
else if(score>=60)
cout <<“及格”;
else
cout <<“不及格”;
return 0;
}