后面那题~~
#include <iostream>
using namespace std;
bool CheckEven(int y){
if(y%2){
cout << "是奇数,程序继续" << endl;
return false;
}else{
cout << "是偶数,请再输入一次" << endl;
return true;
}
}
void PrintSpace(int times){
for (int x = 0;x < times;++x){
cout << " ";
}
}
int main(){
int x,y,z;
int SpaceTimes = 0;
do{
cin >> y;
}while(CheckEven(y));
for (x = 0;x < y;++x){
cout << "*";
}cout << endl;
z = y - 1;
SpaceTimes = (y - 3)/2;
for (x = 0;x < z;++x){
cout << "*" ;
PrintSpace(SpaceTimes);
cout << "*" ;
PrintSpace(SpaceTimes);
cout << "*" << endl;
}
}
|