杭电acm 2091 空心三角形

2010-08-09 23:03

#include<iostream>
using namespace std;

int main()
{
    int n , c = 0;
    char ch;
    
    while((ch = getchar()) != '@')
    {
            
         if(++c != 1)
            cout << endl;   
         cin >> n;
         for(int i = 1; i < n; ++i)
         {
             for(int j = i; j <= (2*n-1)/2; ++j)
                cout << ' ';
             
             cout << ch; if(i != 1)   
             { 
               for(int k = 1; k <= (i-1)*2-1; ++k)
                   cout << ' ';
               cout << ch;
             }
             
             cout << endl;
         }
         
         for(int i = 1; i <= 2*n -1; ++i) 
            cout << ch; 
         cout << endl;      

         while(getchar()!='\n'); //去掉缓冲中的回车 

    }
    
    return 0;
}   

发表评论

电子邮件地址不会被公开。 必填项已用*标注