gpt4 book ai didi

c++ - 英尺到米的单位换算

转载 作者:行者123 更新时间:2023-11-28 07:54:13 24 4
gpt4 key购买 nike

<分区>

我必须编写一个程序,读取以英尺和英寸为单位的长度,并输出以米和厘米为单位的等效长度。我必须创建三个函数:一个用于输入,一个或多个用于计算,一个用于输出;并包含一个循环,使用户可以对新的输入值重复此计算,直到用户说他或她想要结束程序。我似乎无法从一个函数中获取输入以用于转换函数,然后由下一个函数输出。我怎么做?谢谢。

#include <iostream>
#include <conio.h>

using namespace std;

double leng;

void length(double leng);
double conv(double leng);
void output(double leng);


int main()
{
length(leng);
conv(leng);
output(leng);

_getche();
return 0;
}

void length(double leng)
{
cout<<"Enter a length in feet, then enter a length in inches if needed: ";
cin>>leng;
return;
}

double conv(double leng)
{
return leng = leng * .3048;
}

void output(double leng)
{
cout<<"Your input is converted to "<<leng;
return;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com