多个因变量一个函数如何使用调用函数

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图

写程序:输入长方体的长宽高,输出其体积和三个面的面积。要求:计算代码单独写在同一个函数中。

运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

你题目的解答代码如下:

#include <stdio.h>
float s1, s2, s3;
float v(float a, float b, float c)
{
    s1 = a * b;
    s2 = a * c;
    s3 = b * c;
    return a * b * c;
}
void main(void)
{
    float a, b, c;
    scanf("%f%f%f", &a, &b, &c);
    printf("V=%.3f\n", v(a, b, c));
    printf("S1=%.3f S2=%.3f S3=%.3f\n", s1, s2, s3);
}

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

C++还是C语言啊
C代码:

#include <stdio.h>
void fun(double a,double b,double c)
{
    double tj = a*b*c;
    double s1 = a*b;
    double s2 = a*c;
    double s3 = b*c;
    printf("体积:%g,三个面的面积分别为:%g,%g,%g\n",tj,s1,s2,s3);
}
int main()
{
    double a,b,c;
    scanf("%lf %lf %lf",&a,&b,&c);
    fun(a,b,c);
    return 0;
}


C++代码:

#include <iostream>
using namespace std;
void fun(double a,double b,double c)
{
    double tj = a*b*c;
    double s1 = a*b;
    double s2 = a*c;
    double s3 = b*c;
    cout <<"体积:"<<tj<<",三个面的面积分别为:"<<tj<<","<<s1<<","<<s2<<","<<s3;
}
int main()
{
    double a,b,c;
    cin >> a>>b>>c;
    fun(a,b,c);
    return 0;
}