问题描述:
C 语言 空心梯形 输入行数 n 值和首数字字符,在屏幕上输出由数字围起的高和下底宽度均 n 的空心梯形.
要求 :输出的数字是循环的,即输出数字 9 后再输出的数字是 0.
输入 5 5↵
输出
5 6 7 8 9 0 1 0 9 8 7 6 5
6 6
7 7
8 8
9 0 1 0 9↵
1个回答
分类:
综合
2014-09-21
问题解答:
我来补答
#include "stdio.h"/* 画rows行首数字为start的实心梯形 */void drawHollowEchelon(int rows, int start){ int i, j, k; int value; /* 输出上底 */ for(i=0; i<=(3*rows-3)/2; i++) printf("%d", (start+i)%10); for(i=0; i<=(3*rows-4)/2; i++) printf("%d", (start+(3*rows-3)/2+(rows%2==0?0:-1)-i+10)%10); printf("\n"); for(i=0; i24 || start<0 || start>9); drawHollowEchelon(rows, start);}输出结果:
展开全文阅读