zoukankan      html  css  js  c++  java
  • 上机实验

    源程序代码:

    package junit01;

    public class triangle {
     public String s(int a,int b,int c){
      if(a + b <= c||b + c <= a||a + c <= b||a*b*c <= 0) return("不是三角形");
      else if(a==b && b==c) return("等边三角形");
      else if((a==b && b!=c)||(b==c && c!=a)||(a==c && c!=b)) return("等腰三角形");
      else return("一般三角形");
     }
    }

    Test代码:

    package junit01;

    import static org.junit.Assert.*;

    import org.junit.Assert;
    import org.junit.Before;
    import org.junit.Test;

    public class triangleTest2 {
     private triangle t;
     @Before
     public void setUp() throws Exception {
      t = new triangle();
     }

     @Test
     public void testS() {
      Assert.assertEquals("不能判断是否为三角形","不是三角形",t.s(5,5,11));
      Assert.assertEquals("不能判断是否为等边三角形","等边三角形",t.s(6,6,6));
      Assert.assertEquals("不能判断是否为等腰三角形","等腰三角形",t.s(2,2,3));
      Assert.assertEquals("不能判断是否为一般三角形","一般三角形",t.s(3,4,5));
     }
    }

  • 相关阅读:
    【[CQOI2015]选数】
    杜教筛
    【[CQOI2009]跳舞】
    【简单的数学题】
    【[SDOI2013]泉】
    【[AHOI2013]差异】
    【[HEOI2016/TJOI2016]序列】
    【[SDOI2008]Sandy的卡片】
    linux系统编程之信号(一)
    linux系统编程之进程(五)
  • 原文地址:https://www.cnblogs.com/aisingiorohanani/p/5295602.html
Copyright © 2011-2022 走看看