博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
单元测试
阅读量:4701 次
发布时间:2019-06-09

本文共 775 字,大约阅读时间需要 2 分钟。

简单的例子:

查找list[]中的最大值:

  int Largest(int list[], int length);

首份实现代码如下:

  int Largest(int list[], int length){

   int i,max;

   for(i = 0; i < (length – 1); i ++ ) {

     if(list[i] > max) {

      max=list[i];

     }

  }

  return max;

  }

修改后的代码:

public class Main {    public static void main(String args[]){        int a[] = {4};        int l = a.length;        System.out.println(Largest(a,l));    }    static int Largest(int list[],int length){        // 对函数的参数进行调试        if(list == null || length != list.length)            return 0;                int i,max = list[0];        for(i = 1;i <= (length - 1);i++){            if(list[i] > max){                max = list[i];            }        }        return max;    }}

 

转载于:https://www.cnblogs.com/twentytwo/p/4594285.html

你可能感兴趣的文章
Android学习笔记之初步学百度地图
查看>>
php中引用&的真正理解
查看>>
为什么软件开发,人多、事少、还会工作量大?
查看>>
[Selenium+Java] How to use IntelliJ IDEA & Selenium Webdriver
查看>>
Oracle创建表
查看>>
RobHess的SIFT代码解析步骤二
查看>>
windows server环境下安装unity3d注意事项
查看>>
C#类、接口、虚方法和抽象方法
查看>>
SpringBoot使用@Value从yml文件取值为空--注入静态变量
查看>>
Windows下Memcached的安装配置方法
查看>>
平台设备驱动之平台驱动
查看>>
C++关键字作用总结
查看>>
Codeforces Round #330 (Div. 2)B. Pasha and Phone 容斥
查看>>
HDU 1536 S-Nim SG博弈
查看>>
laravel学习之路5缓存
查看>>
51Nod 1085 背包问题
查看>>
WindowsPhone App如何扩展能够使用的内存
查看>>
串口调适
查看>>
Outlook 2010开机自启动
查看>>
验证IP地址格式是否正确的js函数
查看>>