package com.aini;

import java.util.Scanner;
//操。。。为什么数组的大小比较我硬是搞不懂,比较大小依然放在for循环里。。。
//从键盘输入一组数据,并输出最小值
//还有循环结构的括号不知道在哪里结束

public class erte {
	public static void count(int a[]) {
		int min = a[0];
		for (int i = 0; i < a.length; i++) {
			if (min > a[i]) {
				min = a[i];
			}
		}

		System.out.println("最小值是:" + min);

	}

	public static void main(String[] args) {
		Scanner c = new Scanner(System.in);

		System.out.println("请输入你所需的整数个数------");
		int x = c.nextInt();
		int a[] = new int[x];
		// int max = a[0];
		// int s = 0;
		for (int i = 0; i < a.length; i++) {
			System.out.println("请输入" + "第" + (i + 1) + "个数");
			a[i] = c.nextInt();

		}
		count(a);

	}

}

  

总结:理解理解。

主要原因:数组内存分配不懂。循环结构。还有比较大小

 

相关文章:

  • 2021-09-27
  • 2021-08-14
  • 2022-12-23
  • 2021-04-06
  • 2021-04-21
  • 2022-03-04
  • 2021-08-09
猜你喜欢
  • 2021-10-03
  • 2021-11-05
  • 2021-06-02
  • 2021-12-24
  • 2022-01-10
相关资源
相似解决方案