使用嵌套循环产生下列图案

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
int main(void)
{
const int ROWS=6;
const int DECL=5;
const int CHARS=11;
int row;
int rot;
int line;
for(row=6;row>=0;row--)
{
for(rot=0;rot<row;rot++)
printf(" ");
int row;
char ch;
for(row=5;row>=ROWS;row--)
{
for(ch=('A'+CHARS);ch>=('A'+row);ch--)
printf("%c",ch);
printf("\n");
}
return 0;
}
*
***
*****
*******
*********
***********
使用嵌套循环产生下列图案
$
$$
$$$
$$$$
$$$$$
#include <stdio.h>
int main(void)
{
const int ROWS=0;
const int CHARS=4;
int row;
int line;
char ch;
ch='$';
for(row=4;row>=ROWS;row--)
printf("*");
printf("\n");
}
return 0;
}
#include <stdio.h>
int main(void)
{
const int ROWS=6;
const int CHARS=11;
int row;
int rot;
int line;
for(row=6;row>=0;row--)
{
for(rot=0;rot<=row;rot++)
printf(" ");
{
for(line=row;line<=CHARS;line++)
printf("%c",ch);
printf("\n");
}
return 0;
}
F
FE
FED
FEDC
FEDCB
FEDCBA
#include <stdio.h>
int main(void)
{
const int ROWS=0;
const int CHARS=5;
for(line=2*row+1;line<=CHARS;line++)
printf("*");
printf("\n");
}
for(row=0;row<=DECL;++row)
{
for(rot=0;rot<=row;rot++)
printf(" ");
for(line=9-2*row;line>0;line--)
for(line=2*row+1;line<=CHARS;line++)
printf("*");
printf("\n");
}
return 0;
}
*
***
*****
*******
*********
***********
*********
*******
*****
***
*
#inclΒιβλιοθήκη Baidude <stdio.h>
相关文档
最新文档