gpt4 book ai didi

c - 函数 `float calcSize(int, int, int, int)' 的参数太少

转载 作者:行者123 更新时间:2023-11-30 20:27:02 25 4
gpt4 key购买 nike

它一直告诉我在 float calcSize() 函数中运行的参数太少,即使我发送了其中的所有 4 个变量。我的另一个问题是,我的程序有意义吗?

#include <stdio.h>
#include <conio.h>
#define PAINT 350.00

//Function Prototype
void displayInstructions();
float calcSize(int , int , int , int );
float calcPaint(float);
float calcCost(float, float);
void displayTotals(float, float, float);

int main()
{
// Variables
int l , w , d, win ;
float s;
float p;
float cP = 32.00;
float c ;

displayInstructions();
//Getting variables
printf("Please enter the number of heights in feet");
scanf("%d",&l);
printf("Please enter the number of width");
scanf("%d",&w);
printf("Please enter the number of doors");
scanf("%d",&d);
printf("Please enter the number of windows");
scanf("%d",&win);

calcSize(l , w , d , win);
calcSize() = s;
calcPaint(s);
calcPaint() = p;
calcCost(p, cP);
calcCost() = c;
displayTotals(s , p , c);

getch();
return 0;
}

//Display function
void displayInstructions()
{
Printf("Welcome to the Green Paint Calculator!");
Printf("\nEnter the height and width of the room (in feet)");
Printf("\nand the number of doors and windows.");
Printf("This program will then calculate how many cans of paint needed");
Printf("\n(based on 2 coats of paint).It will then calculate the cost");
Printf("\nbased on the charge per gallon entered");
}
//Calcsize function
float calcSize(int l, int w, int d, int win)
{
float area, areaDoors, areaWindows;

area = (l + w) * 2 * 8.0;
areaDoors = d * 20;
areaWindows = win * 15;

area -= areaDoors + areaWindows;
return area;
}

//calcPaint function
float calcPaint(float s)
{
float galPaint;

galPaint = s / PAINT * 2;
return galPaint;
}
//calccost function
float calcCost(float p, float cP)
{
return p * cP;
}
//Display total function
void displayTotals(float s, float p, flaot c)
{
printf("\n\nSize of room in square feet: %.2f", s);
printf("\nNumber of gallons needed: %.2f", p);
printf("\nTotal cost to paint room: %.2f", c);
}

最佳答案

你的程序没有任何意义。我不知道您想用 calcSize() = s; 做什么。我觉得应该是这样的

s = calcSize(l , w , d , win); 

如果你想将函数的返回值赋给s

关于c - 函数 `float calcSize(int, int, int, int)' 的参数太少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22575221/

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