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

来源:互联网 发布:java可控参数 编辑:程序博客网 时间:2024/05/19 16:34


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

#include <iostream>using namespace std;#define MAX 5int 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;}


原创粉丝点击