暑假集训第一周比赛G题http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/G

G - 向

Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

把一个字符三角形掏空,就能节省材料成本,减轻重量,但关键是为了追求另一种视觉效果。在设计的过程中,需要给出各种花纹的材料和大小尺寸的三角形样板,通过电脑临时做出来,以便看看效果。

Input

每行包含一个字符和一个整数n(0<n<41),不同的字符表示不同的花纹,整数n表示等腰三角形的高。显然其底边长为2n-1。如果遇到@字符,则表示所做出来的样板三角形已经够了。

Output

每个样板三角形之间应空上一行,三角形的中间为空。显然行末没有多余的空格。

Sample Input

X 2 A 7 @

Sample Output

X

XXX  

A
         A  A
       A      A
     A          A
   A              A
 A                  A
AAAAAAAAAAAAA

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
using namespace std;

void create(char ch, int n);
int main()
{
char ch;
int n, flag=0;
while(cin >> ch, ch!=‘@‘)
{
cin >> n;
if(flag==1)
printf("\n");
else
{
flag=1;
}
create(ch, n);
}
return 0;
}
void create(char ch, int n)
{
int i, j, k;

for(i=0; i<n-1; i++)
{
for(j=0; j<n-i-1; j++)
printf(" ");
if(i!=0)
printf("%c", ch);
for(j=0; j<2*i-1; j++)
printf(" ");
printf("%c\n", ch);
}
for(k=0; k<2*n-1; k++)
printf("%c", ch);
printf("\n");
}

时间: 2024-08-10 19:17:04

暑假集训第一周比赛G题http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/G的相关文章

暑假集训第一周比赛C题http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83146#problem/C

C - 学 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数. Input 每组数据占一行,代表四张卡片上的数字(0<=数字<=9),如

POJ-3126 暑假集训-搜索进阶F题http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/F

经验就是要认真细心,要深刻理解.num #include<iostream>#include<algorithm>#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#include<ctype.h>#include<queue>using namespace std;#define N 11000 typedef struc

8.14比赛j题 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87813#overview

就我个人来说我觉得这道题其实不用写题解,只是因为做的时候错了一次,如果不是队友细心,我根本会错下去,所以我感觉自己必须强大#include<stdio.h> #include<string.h> #include<ctype.h> #include<queue> #include<algorithm> using namespace std; #define N 300100 int n, m, cnt; char str[N]; int v[N

HDU2612 -暑假集训-搜索进阶N http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/N

这两天总是因为一些小错误耽误时间,我希望自己可以细心点.珍惜时间,珍爱生命!#include<iostream> #include<algorithm> #include<string.h> #include<ctype.h> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<limits.h> #include<queue>

POJ3156 暑假集训-最短路H题floyd http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82829#rank

  http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82829#rank#include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<limits.h> #include<mat

WUST暑假集训第一周简单小结

目录 一.dfs序在树状图中的经典应用 二.初探双向广度优先搜索 三.整体二分思想完美解决kth number问题 四.实战模拟退火思想(变步长贪心算法) 五.凸包问题经典例题 六.树的重心问题经典例题 七.矩阵快速幂例题 一.dfs序在树状图中的经典应用 首先是dfs序的问题,什么是dfs序? 我的理解:dfs序也就是将一棵树通过树的遍历顺序将一棵树转化为父节点包含了子节点的序列,n个结点的树对应n个数的序列,一个结点在序列中的表现形式为一段区间,这段区间中包含了该结点的子树区间,且构造的区间

暑假训练第一周总结

本周训练主要训练的知识点主要是并查集,线段树,RMQ,树状数组的以及字典树,ac自动机,二分图,树上dp的复杂形势,lca 开始在刷acm step,刷到并查集的时候,几道题目都不会做,没有学习过并查集,然后看kuangbin并查集,挑战程序设计和红书例题,带权并查集什么的,很简单,切了 然后是二分图,二分图知识以前并不了解,acm step有一章的二分图的题目,求最大匹配或者最大独立集,理解匈牙利算法难度不是很高,了解了一些建图的套路 区间问题用的算法,感觉有些漏洞,uva的题写了几道,其他的

LightOJ 1317 第六周比赛A题

A - A Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Description You probably have played the game "Throwing Balls into the Basket". It is a simple game. You have to throw a ball into a basket from a certain dista

CodeForces 478B 第六周比赛B题

B - B Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair o