Advertisement
andy0130tw

Blogpost: [C++] 巢狀迴圈與圖形輸出 C0

Jul 20th, 2012
3,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     int a;
  5.     while(cin>>a){
  6.         for(int i=1;i<=a;i++){
  7.             for(int j=1;j<=a-i;j++){
  8.                 cout<<" ";
  9.             }
  10.             for(int k=1;k<=2*i-1;k++){
  11.                 cout<<"$";
  12.             }
  13.             cout<<endl;
  14.         }
  15.     }
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement