空心字符菱形

2022-07-27 13:26:18   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《空心字符菱形》,欢迎阅读!
菱形,空心,字符

#include <stdio.h>

int main()

{

int n, i, j;

char c;

scanf("%c %d",&c,&n);

for( i = 1 ; i <= n ; i++ )

{

for( j = 1 ; j <= n + i - 1 ; j++ )

{

if( ( j == n + 1 - i ) || ( j == n - 1 + i ) ) printf("%c",c);

else printf(" ");

}

printf("\n");

c++;

}

c--;

for( i = n - 1 ; i >= 1 ; i-- )

{

c--;

for( j = 1 ; j <= n + i - 1 ; j++ )

{

if( ( j == n + 1 - i ) || ( j == n - 1 + i ) ) printf("%c",c);

else printf(" ");

}

printf("\n");

}

return 0;

}

本文来源:https://www.wddqxz.cn/1d4d0d5d7175a417866fb84ae45c3b3567ecddbd.html

相关推荐