c - 编写 C 程序供用户输入 50 或更少的数字
问题描述
我正在尝试编写一个 C 程序,该程序必须要求用户输入 50 个或更少的数字。我的问题是“或更少”的数字。如何让程序知道用户何时想要停止输入数字?
解决方案
这是您问题的答案:-
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
void main()
{
int a[100],n,i;
printf("Enter the no of inputs u want to give (It must be less than or eqaual to 50)\n");
scanf("%d",&n);
printf("Enter the nos \n");
if(n<=50)
{
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
}
else
printf("Invalid Input \n");
getch();
}
推荐阅读
- c# - 如何将列表存储到数组中,然后通过视图包返回
- ios - App Store 收据中缺少原始应用程序版本
- html - 在jade/pug 中阻止HTML 的整个部分,而不是单独的行
- html - 如何在css中的div边框中间创建一条曲线?
- sql - 如何在 SQL Server 中计算余额?
- python - 用 python 修补 module.object
- python - Python缩进字符串到JSON
- reactjs - Service Worker 注册期间出错:DOMException: Failed to register a ServiceWorker for scope.An SSL certificate error occurred
- getstream-io - 移动后端或前端与 GetStream 的集成
- java - 如何以最佳方式使用 toString 方法与 StringBuilder