C++.Homework.C++Base.01


===========min.h============

#include <iostream>
using namespace std;
#define MAX 5
int min(int a[]);
double min(double a[]);
float min(float a[]);
long min(long a[]);

===========min.cpp=========

#include "min.h"
int min(int a[]){
	int temp=a[0];
	for (int i = 1; i < MAX; i++)
	  if (a[i] < temp)
		temp = a[i];
	  return temp;
}
double min(double a[]){
	double temp = a[0];
	for (int i = 1; i < MAX; i++)
	if (a[i] < temp)
		temp = a[i];
	return temp;
}
float min(float a[]){
	float temp = a[0];
	for (int i = 1; i < MAX; i++)
	if (a[i] < temp)
		temp = a[i];
	return temp;
}
long min(long a[]){
	long temp = a[0];
	for (int i = 1; i < MAX; i++)
	if (a[i] < temp)
		temp = a[i];
	return temp;
}

=========main.cpp=========

#include "min.h"
void main(){
	int i[MAX] = {7,8,4,6,9};
	double d[MAX] = {4545.12,799.456,1565.154,656.124,897.143};
	float f[MAX] = {123.5,454.8,457.4,139.4,457.9};
	long l[MAX] = {123456,745643,45496,54678,565641};
	cout << min(i) << endl << min(d) << endl << min(f) <<endl<< min(l) << endl;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值