求 一道计算机C语言程序题的写法write a program to print a triangle using asterisks,where the triangle has at least a height of three characters.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/19 09:33:39
求 一道计算机C语言程序题的写法write a program to print a triangle using asterisks,where the triangle has at least a height of three characters.
求 一道计算机C语言程序题的写法
write a program to print a triangle using asterisks,where the triangle has at least a height of three characters.
求 一道计算机C语言程序题的写法write a program to print a triangle using asterisks,where the triangle has at least a height of three characters.
一个左对齐的,一个右对齐的,一个倒三角左对齐,一个倒三角右对齐
你根据需要去相应的部分就行
#include "stdio.h"
int main(void)
{
int i,j,k;
for (i = 1; i = 1; k--)
printf("*");
for (j = 4 - i; j >= 1; j--)
printf(" ");
printf("\n");
}//左对齐
printf("左对齐\n");
for (i = 3; i >= 0; i--)
{
for (k = i; k >= 1; k--)
printf(" ");
for (j = 1; j = 1; i--)
{
for (k = i; k >= 1; k--)
printf("*");
for (j = 0; j = 1; i--)
{
for (k = 4 - i; k >= 1; k--)
printf(" ");
for (j = i; j >= 1; j--)
printf("*");
printf("\n");
}//倒右对齐
printf("倒右对齐\n");
return 1;
}