C++写程序输出a+b+c的和
4个回答
展开全部
#include "stdafx.h"
#include <iostream>
void Max2(double a,double b)
{
int max=a>b?a:b,
cout<<"Double a "<<"and"<<" double b's Max is:"<<max<<endl;
return ;
}
void Max2(int a int b)
{
int max=a>b?a:b;
cout<<"Int a "<<"and"<<" int b's Max is:"<<max<<endl;
return ;
}
void Max3(double a,double b,double c)
{
double temp=a>b?a:b;
double max1 = temp1>c?temp:c;
cout<<"Double a "<<", double b "<<"and"<<" double c's Max is:"<<max<<endl;
return;
}
void Max3(int a,int b,int c)
{
double temp=a>b?a:b
double max= temp>c?temp:c;
cout<<"Int a "<<", int b "<<"and"<<" int c's Max is:"<<max<<endl;
}
int main(int argc, char* argv[])
{
double a,b,c;
// int a,b,c;
cin>>a;
cin>>b;
cin>>c;
Max2(a,b);
Max3(a,b,c);
return 0;
}
#include <iostream>
void Max2(double a,double b)
{
int max=a>b?a:b,
cout<<"Double a "<<"and"<<" double b's Max is:"<<max<<endl;
return ;
}
void Max2(int a int b)
{
int max=a>b?a:b;
cout<<"Int a "<<"and"<<" int b's Max is:"<<max<<endl;
return ;
}
void Max3(double a,double b,double c)
{
double temp=a>b?a:b;
double max1 = temp1>c?temp:c;
cout<<"Double a "<<", double b "<<"and"<<" double c's Max is:"<<max<<endl;
return;
}
void Max3(int a,int b,int c)
{
double temp=a>b?a:b
double max= temp>c?temp:c;
cout<<"Int a "<<", int b "<<"and"<<" int c's Max is:"<<max<<endl;
}
int main(int argc, char* argv[])
{
double a,b,c;
// int a,b,c;
cin>>a;
cin>>b;
cin>>c;
Max2(a,b);
Max3(a,b,c);
return 0;
}
追问
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
c:\documents and settings\administrator\桌面\cpp1.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
执行 cl.exe 时出错.
Cpp1.exe - 1 error(s), 0 warning(s)
追答
简单,你把第一行代码给删了
展开全部
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"依次输入a,b,c的值,用空格或者回车分开"<<endl;
cin>>a>>b>>c;
cout<<"a+b+c="<<a+b+c<<endl;
return 0;
}
using namespace std;
int main()
{
int a,b,c;
cout<<"依次输入a,b,c的值,用空格或者回车分开"<<endl;
cin>>a>>b>>c;
cout<<"a+b+c="<<a+b+c<<endl;
return 0;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<iostream>
int main()
{
std::cout<<"Enter three nembers:"<<std::endl;
int a,b,c;
std::cin >>a>>b>>c;
std::cout << "The sum of " << a<< " and " <<b<<"and"<<c
<< " is " <<a + b + c<< std::endl;
system("PAUSE");
return 0 ;
}
int main()
{
std::cout<<"Enter three nembers:"<<std::endl;
int a,b,c;
std::cin >>a>>b>>c;
std::cout << "The sum of " << a<< " and " <<b<<"and"<<c
<< " is " <<a + b + c<< std::endl;
system("PAUSE");
return 0 ;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用你的开发环境(VC6/VC2003/VC2005/VC2008/Vc2010/VC2012)创建个命令行程序工程
然后在那个工程提供的文件中编写你的代码
通过在main函数中调用你的函数完成你的需求.
然后在那个工程提供的文件中编写你的代码
通过在main函数中调用你的函数完成你的需求.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询