【信息学奥赛一本通】题解目录

OJ网站:点击这里

第一章 C++语言入门

目录

第一章 C++语言入门

2060:【例1.1】计算机输出

2061:【例1.2】梯形面积

2062:【例1.3】电影票

2063:【例1.4】牛吃牧草

1001:Hello,World!

1002:输出第二个整数

1003:对齐输出

1004:字符三角形

第二章 顺序结构程序设


1000:入门测试题目

#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a+b;
	return 0;
}

2060:【例1.1】计算机输出

#include <bits/stdc++.h>
using namespace std;
int main(){
	cout<<"Hello World!";
	return 0;
}

2061:【例1.2】梯形面积

#include <bits/stdc++.h>
using namespace std;
int main(){
	cout<<"400.00";
return 0;
}

2062:【例1.3】电影票

#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,ans;
	cin>>x;
	ans=x*10;
	cout<<ans;
	//  也可以直接输出  cout<<x*10; 
	return 0;
}

2063:【例1.4】牛吃牧草

#include <bits/stdc++.h>
using namespace std;
int main(){
    int s1,s2,s3;
    s1=15*20;
    s2=20*10;
    s3=(s1-s2)/(20-10);
    cout<<s3<<endl;
    return 0; 
}

1001:Hello,World!

#include <bits/stdc++.h>
using namespace std;
int main(){
	cout<<"Hello World!";
	return 0;
}

1002:输出第二个整数

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<b;
    return 0; 
}

1003:对齐输出

#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	printf("%8d %8d %8d",a,b,c);  //输出8个空格; 
	return 0;
}

1004:字符三角形

#include <bits/stdc++.h>
using namespace std;
int main(){
	char a;//创建字符; 
	cin>>a;//输入字符 
	cout<<"  "<<a<<endl;
	cout<<' '<<a<<a<<a<<endl;
	cout<<a<<a<<a<<a<<a<<endl;
	//因为规定了格式,可以直接输出 
	return 0;
}

1005:地球人口承载力估计 

#include <bits/stdc++.h>
using namespace std; 
int main(){
    double x,a,y,b;
    scanf("%lf%lf%lf%lf",&x,&a,&y,&b);
    printf("%.2lf",(y*b-x*a)/(b-a));
    return 0;
}

//这道题与牛吃草问题相似;

第二章 顺序结构程序设计

第一节 运算符和表达式

2064:【例2.1】交换值

#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	swap(a,b);//swap用于交换两个数的值; 
	cout<<a<<" "<<b; 
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,t;//t用来做中转站 
	cin>>a>>b; //输入a和b 
	a=t;//假设有一杯可乐和雪碧,t是一个空杯子
	//这里是把可乐倒进空杯子 
	a=b;//把雪碧倒入原来装可乐的杯子
	b=t;//把可乐倒入原来装雪碧的杯子
	cout<<a<<" "<<b//输出 
	return 0;
}

持续更新中......(一周一更)

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值