程序运行,但程序中的第二个函数不打印?输出中没有错误 #包括 #包括 使用名称空间std; int main() { 双a; 双b; a=(3.0); b=(5.0); 如果不是调用函数,则需要使用calculate()从main调用函数,并在使用前声明 #include <iostream> #include <iomanip> using namespace std; int main () { double a; double b; a =(3.0); b =(5.0); cout << " " << fixed << setprecision (1) << a << "\n" << endl; cout << "* " << fixed << setprecision (1) << b << "\n" << endl; cout << "------" << endl; cout << fixed << setprecision (2) << a*b << "\n" << endl; system("PAUSE"); return 0; } int calculate () { double a; double b; double c; a = (7.1); b = (8.3); c = (2.2); cout << fixed << setprecision(1) << endl; cout << " " << fixed << setprecision (1) << a << "\n" << endl; cout << "* " << fixed << setprecision (1) << b << "\n" << endl; cout << "- " << fixed << setprecision (1) << c << "\n" << endl; cout << "------" << endl; cout << std::setprecision(2) << (a * b) - c << "\n" << std::endl; system("PAUSE"); return 0; } 这是非常基本的东西。我建议你读一本介绍性C++书。

程序运行,但程序中的第二个函数不打印?输出中没有错误 #包括 #包括 使用名称空间std; int main() { 双a; 双b; a=(3.0); b=(5.0); 如果不是调用函数,则需要使用calculate()从main调用函数,并在使用前声明 #include <iostream> #include <iomanip> using namespace std; int main () { double a; double b; a =(3.0); b =(5.0); cout << " " << fixed << setprecision (1) << a << "\n" << endl; cout << "* " << fixed << setprecision (1) << b << "\n" << endl; cout << "------" << endl; cout << fixed << setprecision (2) << a*b << "\n" << endl; system("PAUSE"); return 0; } int calculate () { double a; double b; double c; a = (7.1); b = (8.3); c = (2.2); cout << fixed << setprecision(1) << endl; cout << " " << fixed << setprecision (1) << a << "\n" << endl; cout << "* " << fixed << setprecision (1) << b << "\n" << endl; cout << "- " << fixed << setprecision (1) << c << "\n" << endl; cout << "------" << endl; cout << std::setprecision(2) << (a * b) - c << "\n" << std::endl; system("PAUSE"); return 0; } 这是非常基本的东西。我建议你读一本介绍性C++书。,c++,visual-studio-2010,C++,Visual Studio 2010,你不是要调用函数,你需要从主调用它,用计算()/Cord>并在使用前声明。< /P> #include <iostream> #include <iomanip> using namespace std; int main () { double a; double b; a =(3.0); b =(5.0); cout << " " << fixed << setprecision (1) << a <<

你不是要调用函数,你需要从主调用它,用<代码>计算()/Cord>并在使用前声明。< /P>
#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{
double a;
double b;
a =(3.0);
b =(5.0);
cout << "  " << fixed << setprecision (1) << a << "\n" << endl;
cout << "* " << fixed << setprecision (1) << b << "\n" << endl;
cout << "------" << endl;
cout << fixed << setprecision (2) << a*b << "\n" << endl;
system("PAUSE");

return 0;
}

int calculate ()
{
   double a;
   double b;
   double c;
   a = (7.1);
   b = (8.3);
   c = (2.2);
   cout << fixed << setprecision(1) << endl;
   cout << "  " << fixed << setprecision (1) << a << "\n" << endl;
   cout << "* " << fixed << setprecision (1) << b << "\n" << endl;
   cout << "- " << fixed << setprecision (1) << c << "\n" << endl;
   cout << "------" << endl;
   cout << std::setprecision(2) << (a * b) - c << "\n" << std::endl;

system("PAUSE");

return 0;
}

<>这是非常基本的东西。我建议你读一本介绍C++的书。

<代码>计算器()>代码>似乎不被调用…..你不调用主体中的计算函数?你没有调用<代码>计算< /代码>任何地方在代码>主< /代码>。请不要把括号围绕常量值。<代码>(3)的意思与
3.0
相同,但更难阅读。
calculate()
似乎没有被调用..?您没有在主体中调用calculate函数?您没有在
main
中的任何地方调用
calculate
。请不要在常量周围加括号。
(3.0)
的意思与
3.0
相同,但更难理解。很抱歉,我不明白“从主节点调用”的意思。我可以通过设置参数声明它:int calculate(int a,int b,int c)?@JustinChiang如果你不知道调用函数意味着什么,你可能需要读一本好书。哦,我现在明白多了!谢谢你的例子!很抱歉,我不明白你说的“从main调用它”是什么意思。我可以通过设置参数来声明它:int calculate(int a,int b,int c)?@JustinChiang如果你不知道调用函数意味着什么,你可能需要找到一本好书。哦,我现在明白多了!谢谢你的例子!