1.交换值
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=2064
代码:
#include<iostream>
using namespace std;
int a,b,c;//定义变量
int main()
{
cin>>a>>b;
c=a;
a=b;
b=c;//交换
cout<<a<<" "<<b;
return 0;
}
2. 整数的和
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=2065
代码:
#include<iostream>
using namespace std;
int a,b,c;//定义变量
int main()
{
cin>>a>>b>>c;//输入
cout<<a+b+c<<endl;//输出
return 0;
}
3.买图书
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=2066
代码:
#include<iostream>
using namespace std;
double n,m;//定义变量
int main()
{
cin>>n>>m;//输入
m=m*0.8;
n=n-m;//计算
printf("%.2lf",n);//printf可保留两位小数
return 0;
}
4.A+B问题
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=1006
代码:
#include<iostream>
using namespace std;
int n,m;//定义变量
int main()
{
cin>>n>>m;//输入
cout<<n+m<<endl;//输出
return 0;
}
5.计算(a+b)*c的值
代码:
#include<iostream>
using namespace std;
int a,b,c,d;
int main()
{
cin>>a>>b>>c;//输入
d=a+b;
d=c*d;//计算
cout<<d<<endl;
return 0;
}
6.计算(a+b)/c的值
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=1008
代码:
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
cin>>a>>b>>c;//输入
cout<<(a+b)/c<<endl;//计算、输出
return 0;
}
7.带余除法
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=1009
代码:
#include<iostream>
using namespace std;
int a,b;
int main()
{
cin>>a>>b;//输入
cout<<a/b<<" "<<a%b<<endl;//计算、输出
return 0;
}
8.计算分数的浮点数值
原题链接http://ybt.ssoier.cn:8088/problem_show.php?pid=1010
代码:
#include<iostream>
using namespace std;
int a,b;//定义
int main()
{
cin>>a>>b;
printf("%.9lf",a*1.0/b); //保留9位小数
return 0;
}
新手,请多多指教