c语言编程 打印图形,菜单包括:矩形,平行四边形,输入图形的行数、列数并输入打印的字符,打印出图形
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/16 00:05:15
c语言编程 打印图形,菜单包括:矩形,平行四边形,输入图形的行数、列数并输入打印的字符,打印出图形
#include
#define true 1
void print(char cType, int iRow, int iColumn, char cMark)
{
int i,j;
if(cType == 'A')
{
for(i = 0; i < iRow; i++)
{
for(j = 0; j < iColumn; j++)
{
printf("%c ", cMark);
}
printf("\n");
}
}
else if(cType == 'B')
{
for(i = 0; i < iRow; i++)
{
for(j = iRow; j > i; j--)
{
printf(" ");
}
for(j = 0; j < iColumn; j++)
{
printf("%c ", cMark);
}
printf("\n");
}
}
else
{
printf("Error\n");
}
}
int main()
{
int iRow;
int iColumn;
char cType;
char cMark;
while(true)
{
printf("Please select the graph you want to print \nA. Rectangle B. Parallelogram Q. Quit\n");
scanf("%c", &cType);
getchar();
if(cType != 'A' && cType != 'B' && cType != 'Q')
{
printf("\nInput illegal\n\n");
continue;
}
if(cType == 'Q')
{
return 0;
}
printf("Please input the number of rows: ");
scanf("%d", &iRow);
printf("Please input the number of columns: ");
scanf("%d", &iColumn);
printf("Please input the charactor you want to print : ");
getchar();
scanf("%c", &cMark);
getchar();
print(cType, iRow, iColumn, cMark);
}
return 0;
}
#define true 1
void print(char cType, int iRow, int iColumn, char cMark)
{
int i,j;
if(cType == 'A')
{
for(i = 0; i < iRow; i++)
{
for(j = 0; j < iColumn; j++)
{
printf("%c ", cMark);
}
printf("\n");
}
}
else if(cType == 'B')
{
for(i = 0; i < iRow; i++)
{
for(j = iRow; j > i; j--)
{
printf(" ");
}
for(j = 0; j < iColumn; j++)
{
printf("%c ", cMark);
}
printf("\n");
}
}
else
{
printf("Error\n");
}
}
int main()
{
int iRow;
int iColumn;
char cType;
char cMark;
while(true)
{
printf("Please select the graph you want to print \nA. Rectangle B. Parallelogram Q. Quit\n");
scanf("%c", &cType);
getchar();
if(cType != 'A' && cType != 'B' && cType != 'Q')
{
printf("\nInput illegal\n\n");
continue;
}
if(cType == 'Q')
{
return 0;
}
printf("Please input the number of rows: ");
scanf("%d", &iRow);
printf("Please input the number of columns: ");
scanf("%d", &iColumn);
printf("Please input the charactor you want to print : ");
getchar();
scanf("%c", &cMark);
getchar();
print(cType, iRow, iColumn, cMark);
}
return 0;
}
c语言编程 打印图形,菜单包括:矩形,平行四边形,输入图形的行数、列数并输入打印的字符,打印出图形
c语言问题 打印图形,菜单包括:直角三角形、等腰三角形,输入图形的行数并输入打印的字符,打印出图形.
C程序打印如下图形 * *** ...输入行数n,则打印高度为n的三角形图案
C语言编程 打印数字字符图案 输入任意整数n,输出n行由数字构成的三角形字符阵列图形.
输入任意整数n后,用C语言编程实现打印n行三角字符阵列图形
C语言打印下列图形~输入一个数据n,由该数据决定其三角形的行数,输出其三角形的图形,*之间的间隔数也由用户输入m决定例如
c#输入一个行数打印90度的等腰三角形 图形如下: * * * * * * * * * * * * * * * *
C语言 编写程序,打印如图所示字符图形
C语言 使用循环结构编程打印如下图形:* * * * * * * * * * * * * * * * * * * * *
C语言程序填空 打印以下图形
C语言for循环打印图形问题
编写一个程序打印如下图形:(行数由键盘输入(1~9)范围的值)例下面是输入4的情况.4444444 33333 222