/** * */ package com.cn.u4; import java.util.Scanner; /** * @author Administrator *猜数游戏 */ public class GuessNum { public static void main(String[] args) { int[] nums=new int[]{2,3,6,20,69}; int sum=0; for(int num:nums){ sum+=num; } System.out.println("sum="+sum); Scanner input=new Scanner(System.in); System.out.print("请输入一个数字"); int innum=input.nextInt(); int sameCount=0; for(int i=0;i<nums.length;i++){ if(innum==nums[i]){ sameCount++; break; } } if(sameCount>0){ System.out.println("包含"); }else{ System.out.println("不包含"); } System.out.println("程序结束"); } }