Files
C_code/C语言/翁凯C语言/5/数组来统计个数.c
T
Serendipity 93c16edb5a 更新MD文件路径引用
- 修正主README.md中的所有路径引用,使其与当前文件结构一致
- 更新翁凯C语言学习指南链接路径
- 更新五子棋AI项目文档链接路径
- 更新数据结构学习文档链接路径
- 修正编译说明和学习模块使用指南中的目录路径
- 改进五子棋README.md的编译运行说明,增加Windows和Linux/macOS的分平台指导
- 确保所有文档链接和路径引用都能正确工作
2025-10-17 10:52:27 +08:00

44 lines
658 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
int main()
{
int a[10]={0};
int count=0;
while(1)
{
int b;
printf("请输入一个数字:");
scanf("%d",&b);
if(b==-1)
{
break;
}
if (b<=-1 || b>=10)
{
printf("输入错误,请重新输入\n");
continue;
}
if (count<10)
{
printf("数组已满\n");
break;
}
a[b]++;
count++;
}
for (int i = 0; i < 10; i++)
{
printf("%d: %d\n", i, a[i]);
}
return 0;
}