VC编程环境下灵活运用

第一个实验:

#include<iostream>
using namespace std;
float output(float x,float y)
{
float sum;
sum=x+y;
return sum;
}
int output(int x,int y)
{
int sum;
sum=x+y;
return sum;
}
float input(float a,float b)
{
float end;
end=a*b;
return end;
}
int input(int a,int b)
{
int end;
end=a*b;
return end;
}
int main()
{
float f;
float g;
float jia;
    float cheng;
cout<<"请输入两个小数:"<<endl;
    cin>>f;
cin>>g;
jia=output(f,g);
cout<<"加法="<<jia<<endl;
cheng=input(f,g);
cout<<"乘法="<<cheng<<endl;
    cout<<"请输入两个整数:"<<endl;
int z,v;
cin>>z;
cin>>v;
cout<<"加法="<<output(z,v)<<endl;
cout<<"乘法="<<input(z,v)<<endl;
return 0;
}


第二个实验:效果与上图相同

#include<iostream>
using namespace std;
template<class T>
float output(T x,T y)
{
return x+y;
}
float input(float a,float b)
{
return a*b;
}
int input(int a,int b)
{
return a*b;
}
int main()
{
float f,g;
    cout<<"请输入两位小数:"<<endl;
cin>>f;
cin>>g;
cout<<"加法="<<output(f,g)<<endl;
cout<<"乘法="<<input(f,g)<<endl;
int z,v;
cout<<"请输入两位整数:"<<endl;
cin>>z;
cin>>v;
cout<<"加法="<<output(z,v)<<endl;
cout<<"乘法="<<input(z,v)<<endl;
    return 0;
}

老师,第三个实验多文件编译不会做,有些许问题,我不知道怎么弄才能让头文件可以共享于整个工程中
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值