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

    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

     

     

  • 相关阅读:
    Git连接Github
    全民来打飞机~~(设计探讨)
    mongo学习
    redis aop持久化
    redis的超时删除策略
    redis 学习,没事的时候看看增长知识面
    MySQL query / clause execution order
    用redis做超时判断 感觉写的很有意思
    python 编码问题(转载)
    git 个人学习
  • 原文地址:https://www.cnblogs.com/hyylgz/p/5488582.html
Copyright © 2011-2022 走看看