1. 首页
  2. 其他语言
  3. C/C++

C语言程序在不使用数组的情况下找到“N”个数字中的最大数字?



参考以下代码实现:

c
#include
int main()
{
int count = 0;
int numb1 = 0;
int numb2 =0;
int i =0;
printf("Enter count of numbers = ");
scanf("%d",&count);
if(count <= 0) { printf("Enter valid count\n"); return 0; } printf("Enter the number = "); scanf("%d",&numb1); //loop to get next number for(i =1; i< count ; ++i) { printf("Enter the number = "); scanf("%d",&numb2); if(numb1 < numb2) { numb1 = numb2; } } printf("Largest number is = %d\n",numb1); return 0; }

运行输出结果如下:

![225325_73242.jpg](https://www.java1024.site:9000/shiti/2022/05/20/c49f19e8-3bd2-4234-b3b0-85a4f9505d35.jpg)

发布者:admin,如若转载,请注明出处:https://ai1024.vip/37094.html

QR code
//