题意:输出一个高度为n的三角形
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2091
思路:模拟,乱搞一下就行。
注意点:无
PS:下午考六级,切水题放松下。
以下为AC代码:
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
12545921 | 2014-12-20 12:17:47 | Accepted | 2091 | 0MS | 1104K | 1016 B | C++ | luminous11 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char c;
int flag = 0;
while ( scanf ( "%c", &c ) )
{
if ( c == '@' )
{
return 0;
}
if ( flag )
{
printf ( "\n" );
}
else
{
flag = 1;
}
int num;
scanf ( "%d", &num );
for ( int i = 0; i < num - 1; i ++ )
{
for ( int j = num - i - 1; j > 0; j -- )
{
printf ( " " );
}
printf ( "%c", c );
if ( i == 0 ){printf("\n");continue;}
for ( int j = 0; j < 2 * i- 1; j ++ )
{
printf ( " " );
}
printf ( "%c\n", c );
}
for ( int i = 0; i < num * 2 - 1; i ++ )
{
printf ( "%c", c );
}
printf ( "\n" );
getchar();
}
return 0;
}