引用:
|
作者bluse
int main()
{
for(int j = 5;j>0;j--){
if(j%2 != 0)
for(int i = 0;i<j;i++){
cout<<'*';
}
else cout<<'\n';
}
for(int n = 2;n<6;n++){
if(n%2 != 0)
for(int m = 0; m<n;m++){
cout<<'*';
}
else cout<<'\n';
}
system("pause");
return 0;
}
|
厄...可以這樣回古文嗎....
不過這種題目用一個迴圈就可以了..
main() {
int j, n;
for (j=1; j<=5; j++) {
for (n=1; n<=(abs(j-3)+1)*2-1; n++ ) {
cout << '"*";
}
cout << "\n";
}
}
也就是找出 (1, 2, 3, 4, 5) 跟 (5, 3, 1, 3, 5) 兩個數列之間的方程式即可.