您的位置:首页 > 编程语言 > C语言/C++

C语言 数组之无限循环

2016-01-25 18:56 357 查看
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>

//定于数组的大小
#define N 10

void main(){
//某些场合,我们可能不是要遍历数组,而是重复的遍历这个数组,我偶然学到了这个方法

int a
= { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int index = 0;
while (1){
//确保数组不会越界
if (index>N - 1)
{
index = 0;
//每一次循环来个换行
printf("\n");
Sleep(2000);
}
//做自己想实现的操作
printf("%5d",a[index]);
index++;
}
system("pause");
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: