• 实验三


    1、

    import java.io.BufferedReader;

    import java.io.IOException;

    import java.io.InputStreamReader;

    public class ApproximateName {
    /**
    * @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

     

     

  • 相关阅读:
    Apache HttpClient 4.3.6 API
    java中double的四舍五入 BigDecimal
    Java--获取request中所有参数的方法
    request.getSession(true)和request.getSession(false)的区别
    jquery插件分页
    Qt 之模型/视图(自定义按钮)
    在QTableView中使用各种自定义委托
    tableview setData 设置数据(结构体对象)
    libcurl 使用
    qt MessageBOX 消息
  • 原文地址:https://www.cnblogs.com/hyylgz/p/5488582.html
Copyright © 2020-2023  润新知