循环的嵌套变式

依赖外部循环的嵌套循环:

#include “stdio.h”

void main()

{

const int ROWS=6;

const int CHARS=6;

int row;

char ch;

for(row=0;row<ROWS;row++)

{

for(ch=(‘A’+row);ch<(‘A’+CHARS);ch++)

printf(“%c”,ch);

printf(“n”);

}

}

输出为:

ABCDEF

BCDEF

CDEF

DEF

EF

F

在这里说明一下const.

const限定符(只读),例如:const int a=12;//表示a值为12,且在程序中不可更改。

Int * const p=&a;//p不变

Const int * p=&a//a不变

*p为指针变量,在之后的学习中会学到,是C语言中非常重要的一部分。