以下是我讓它複雜化的題目…
#include <iostream>
using namespace std;
void main(){
int intStar, intStar2, intLine, intDoline, intSpace, intSpace2;
char charWord;
cout << "Enter the base size: ";
cin >> intStar;
cout << "Enter the symbol: ";
cin >> charWord;
intStar2 = intStar;
intLine = 1;
intSpace = 1;
intSpace2 = 2;
if(intStar % 2 == 0){
intDoline = intStar;
}else{
intDoline = intStar + 1;
}
while(intLine < intDoline){
if(intLine <= intDoline / 2){
intSpace2 = intSpace;
while(intSpace > intLine){
cout << " ";
intSpace--;
}
while(intStar >= 1){
cout << charWord;
intStar--;
}
intStar2 = intStar2 - 2;
intStar = intStar2;
intSpace = intSpace2;
intSpace = intSpace + 2;
intLine++;
cout << "\n";
}else{
intSpace = intSpace2;
while(intSpace > intLine){
cout << " ";
intSpace--;
}
intStar = intStar + 3;
intStar2 = intStar;
while(intStar >= 0){
cout << charWord;
intStar--;
}
intStar = intStar2 - 1;
intSpace = intSpace2;
intSpace = intSpace - 2;
intLine++;
cout << "\n";
}
}
system("pause");
}
0 件のコメント:
コメントを投稿