赞
踩
解析:这题主要考察变量定义,输入输出,循环的应用。
#include<iostream>
using namespace std;
int main()
{
char c;
cin>>c;
for(int i=0;i<=2;i++){
for(int j=0;j<=3;j++){
cout<<c;
}
cout<<endl;
}
return 0;
}
解析:主要考察算式应用
#include<iostream>
using namespace std;
int main()
{
int a,b,S;
cin>>a>>b;
S=a*b;
cout<<S;
return 0;
}
解析:if循环的实际应用。
#include<iostream> using namespace std; int main() { int score; cin>>score; if(score>=90 && score<=100){ cout<<"A"; }else if(score>=77 && score<=89){ cout<<"B"; }else if(score>=67 && score<=76){ cout<<"C"; }else if(score>=60 && score<=66){ cout<<"D"; }else{ cout<<"E"; } return 0; }
解析:会使用循环镶嵌,定义标识
#include<iostream> using namespace std; int main() { int a,num,min=-1; cin>>a; for(int i=0;i<a;i++){ cin>>num; if(min==-1){ min = num; cout<<'N'<<endl; }else{ if(min>num){ min = num; cout<<'N'<<endl; }else{ cout<<'Y'<<endl; } } } return 0; }
解析:while无限循环的应用,灵活应用整除取余。
#include<iostream> using namespace std; int main() { int num,a,b,c,d; cin>>num; while(true){ num+=1; a = num/1000; b = num%1000/100; c = num%100/10; d = num%10; if(a+b+c+d==20){ cout<<num; break; } } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。