首页 > 学院 > 开发设计 > 正文

HDU-2091-空心三角形(入门题)

2019-11-06 06:48:57
字体:
来源:转载
供稿:网友
//传送门:http://acm.hdu.edu.cn/showPRoblem.php?pid=2091#include <queue>#include <functional>#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <assert.h>using namespace std;#define N 100005//坑点:注意行末不要有空格; 注意仅在图形间换行char ch;int main(){   bool flag = 0;    while(scanf("%c",&ch),ch!='@'){  //不建议使用 scanf("%c",ch) 或者 getchar()  因为会取走回车; 建议用 scanf("%s",s) 或者 cin>>sting 注意这时候要用"@"      if(flag) printf("/n");      flag = 1;      int n;      scanf("%d",&n);      getchar();                     //取走输入n后 按的回车      for(int i=0;i<n;i++){          //算是比较简洁的写法         for(int j=0;j<i+n;j++){            if(j==n-1-i || j==n-1+i || i==n-1) printf("%c",ch);            else printf(" ");         }         printf("/n");      }    }    return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表