水曜日, 10月 10, 2007

清功課

在亂來的情況下給我以笨蛋的腦筋完全了原本非常簡單,卻讓我變得複雜化。剩下的功課還有一條C++的問題和故事的起承轉合,其他留在明天說。

以下是我讓它複雜化的題目…

#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 件のコメント: