资源描述:
《c语言典型例题——关于图形输出》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、在C语言学习中我们会遇到各种输出图形的题目,下面我们就来看一些这种题目。一、编写程序输出下图所示的图形。(1)(2)(3)(11)下面我们分别以i、j、k分别表示行数,空格数,星号数。(1)ijk(2)ijk(3)ijk101161109202252217303343325404434433505525541606616j<=i-1707707k<=11-2*iK<=ij<=7-iK<=i发现行数、空格、星号有如上关系,用for循环便可实现。istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislo
2、catedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture(1)#include"stdio.h"voidmain(){inti,j;for(i=1;i<=7;i++){for(j=1;j<=i;j++)printf("*");printf("");}}(2)#include"stdio.h"voi
3、dmain(){inti,j,k;for(i=1;i<=7;i++){for(j=1;j<=7-i;j++)printf("");for(k=1;k<=i;k++)printf("*");printf("");}}(3)#include"stdio.h"voidmain()istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPl
4、ateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture{inti,j,k;for(i=1;i<=6;i++){for(j=1;j<=i-1;j++)printf("");for(k=1;k<=11-2*i;k++)printf("*");printf("");}}然后我们在进行扩展。编写程序输出如下图型。(4)(5)(6)所编程序如下:(4)#include"stdio.h"voidmain(){inti,j,k;for(i=1;i<=7;i++){for(j
5、=1;j<=8-i;j++)printf("*");printf("");istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture}}(5)#in
6、clude"stdio.h"voidmain(){inti,j,k;for(i=1;i<=7;i++){for(j=1;j<=i-1;j++)printf("");for(k=1;k<=8-i;k++)printf("*");printf("");}}(6)#include"stdio.h"voidmain(){inti,j,k;for(i=1;i<=5;i++){for(j=1;j<=7-i;j++)printf("");for(k=1;k<=2*i-1;k++)printf("*");printf("");}}istheTibetanPlateaupoly.Centercityo
7、nlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIsl