撰寫程式,主函式中宣告三個變數,呼叫輸入函式input從鍵盤接收三個資料,存入這三個變數中,再呼叫findMax函式找出三數中最大的數,最后于主函式中將最大的數輸出到螢屏上。
幫我把輸入函式改成指標輸入的,簡單一點,我是C++初學者
#include<iostream>
using namespace std;
float input(float s);
float findMax(float a,float b,float c);
main()
{
float a,b,c,max;
cout<<"輸入三個資料"<<endl;
a=input(a);
b=input(b);
c=input(c);
max=findMax(a,b,c);
cout<<"三個數中的最大值為:"<<max<<endl;
}
float input(float s)
{
cin>>s;
return s;
}
float findMax(float a,float b,float c)
{
float max;
max=a;
if(b>max)
max=b;
if(c>max)
max=c;
return max;
}
uj5u.com熱心網友回復:
搞不清意思float input(float &s)
{
scanf("%f\n", &s)
return s;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/93028.html
標籤:基礎類
