当前位置:网站首页>一本通顺序结构程序设计题解(第一章)
一本通顺序结构程序设计题解(第一章)
2022-07-27 05:04:00 【竹林居士-】
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;
}新手,请多多指教
边栏推荐
猜你喜欢
随机推荐
Redis publish subscribe mode
JS中是如何使用for..of来遍历对象
flask一对多数据库创建,基础增删改查
pytorch安装新坑
背景图片相关应用-铺满,自适应
云E办项目之部门管理
思考一些文件的作用
Initial C language -- the function of keyword static
Xiaomi mall project_ register
Time complexity and space complexity
Introduction to C language pointer
Share a multiple-choice question about variables (including global variables, local variables, the scope of variables, and life cycle knowledge points)
SQL(MySql)菜鸟教程知识
elment-ui使用方法
JS中for...of和for...in的区别
正则表达式
C language string introduction and related operation functions
JS中什么是DOM和BOM
qsort — c语言中自带的排序函数(附带void*、回调函数知识点
后台用户管理展示添加功能实现









