zoukankan      html  css  js  c++  java
  • Program1-1

    package com.algo;
    
    import java.util.Random;
    import java.util.Scanner;
    
    public class P1_1 {
    	static int N=20;
    	public static void main(String[] args){
    		int[] arr = new int[N];
    		int x,i;
    		int f = -1;
    		
    		Random r = new Random();
    		for(i=0; i<N; i++){
    			arr[i]=r.nextInt(100);
    		}
    		
    		System.out.println("随机生成的数据序列:");
    		for(i=0; i<N; i++){
    			System.out.print(arr[i]+" ");			
    		}
    		System.out.println();
    		System.out.println();
    		System.out.println("输入要查找的整数:");
    		Scanner input = new Scanner(System.in);
    		x=input.nextInt();
    		
    		for(i=0; i<N; i++){
    			if(x==arr[i]){
    				f=i;
    				break;
    			}
    		}
    		if(f<0){
    			System.out.println("没有找到数据:"+x);
    		}else{
    			System.out.println("数据:"+x+" 位于数组的第  "+(f+1)+" 个元素处
    ");
    		}
    		
    	}
    
    }
    /*
    随机生成的数据序列:
    64 35 61 51 83 11 4 35 7 34 90 34 32 98 95 53 66 9 90 72 
    
    输入要查找的整数:
    11
    数据:11 位于数组的第  6 个元素处
    */
    

  • 相关阅读:
    spark 中划分stage的思路
    如何带人
    技术管理
    学会谈判
    绩效评估与绩效反馈
    企业文化如何落地
    绩效沟通的best原则
    Area POJ
    Cows POJ
    Grandpa's Estate POJ
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5163176.html
Copyright © 2011-2022 走看看