zoukankan      html  css  js  c++  java
  • 实验三

    1.

    import java.io.BufferedReader;

    import java.io.IOException;

    import java.io.InputStreamReader;

    public class Demo {
    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int a = 0;
    System.out.print("请输入m:");
    BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
    try {
    a=Integer.parseInt(strin.readLine());

    } catch (NumberFormatException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    int b = 0;

    System.out.print("请输入一个n:");
    BufferedReader strin2=new BufferedReader(new InputStreamReader(System.in));
    try {
    b=Integer.parseInt(strin2.readLine());
    } catch (NumberFormatException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    int flag = 0;
    for (int i = 1; i <= a; i++) {
    if(a%i==0){
    if(b%i==0){
    flag=i;}
    }
    }
    System.out.println("最大公约数为"+flag);
    }
    }

    2.

    Private Judge(){

    Public static void main(string[]args){

    Scanner scanner =new Scanner(System.in) ;

    Int x=scanner.nextInt();

    Int y=scanner.nextInt();

    Int result=scanner.nextInt();

    If(x<4 or y>0)

    {

       If(y>1){

         Y=y+1;

         }

       Else{

    Return result;

    }

    Else{

       If(x>=5){

    X=x-y;

    }

    Else

    {

    X=x+y

    }

    }

    语句覆盖:

    X=6         y=0             路径aef

    X=1          y=2            路径abc

    分支覆盖:

    X=6/4      y=1             路径aef/aeg

    X=1       y=2/1              路径abc/abd

     

  • 相关阅读:
    二极管常用
    金属化孔与非金属化孔
    电容~3.钽电容
    电感~2.电路分析
    交流整流之后
    电容~2.电路分许
    三极管~3常见电路
    三极管~2.电路分析
    名词解释
    硬件设计
  • 原文地址:https://www.cnblogs.com/echo1561/p/5446337.html
Copyright © 2011-2022 走看看