满意答案
su1254891
2014.01.12
采纳率:55% 等级:13
已帮助:9689人
#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;
}
01分享举报