当前位置:网站首页>洛谷入门2【分支结构】题单题解
洛谷入门2【分支结构】题单题解
2022-06-27 15:23:00 【阳懿】
目录
【入门2】分支结构 - 题单 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
闰年判断
- ①400的倍数
- ②是4的倍数但不是100的倍数
if((n%4==0&&n%100!=0)||n%400==0)肥胖问题
- 在输出时,请四舍五入保留六位有效数字输出,如果小数部分存在后缀 00,不要输出后缀 00。
- 可用%g
(106条消息) 保留有效位数;保留小数点后n位;_阳懿的博客-CSDN博客
printf("%.6g\nOverweight", criterion);三位数排序

不高兴的津津
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int a[7], b[7],sum[7],max=0,k;
for (int i = 0; i < 7; i++)
{
cin >> a[i] >> b[i];
}
bool happy = true;
for (int i = 0; i < 7; i++)
{
sum[i] = a[i] + b[i];
if (sum[i] > 8)
{
happy = false;
}
if (sum[i] > max)
{
max = sum[i];
k = i;
}
}
if (happy == true)
cout << "0";
if (happy == false)
cout << k+1;
return 0;
}买铅笔
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
int n,a;
double pencil[3], sum[3];
long long price[3];
cin >> n;
for (int i = 0; i < 3; i++)
{
cin >> pencil[i] >> sum[i];
}
for (int i = 0; i < 3; i++)
{
price[i]=ceil(n / pencil[i])*sum[i];
}
cout<<min(price[2],min(price[0], price[1]));
return 0;
}ISBN号码
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
string a;
int sum = 1,sbm=0;
char x = 'X';
cin >> a;
for (int i = 0; i < 11; i++)
{
if (isdigit(a[i]))
{
sbm += (a[i]-'0') * sum;
++sum;
}
}
sbm %= 11;
if (a[12] == 'X'&&sbm == 10)
{
cout << "Right";
}
else if (a[12]!='X' && a[12]-'0' == sbm)
{
cout << "Right";
}
else
{
for (int i = 0; i < 12; i++)
{
cout << a[i];
}
if (sbm == 10)
cout << "X";
else
cout << sbm;
}
return 0;
}小鱼的航程
#include<iostream>
using namespace std;
int main() {
int n, x,a=0;
cin >> x >> n;
//直接总体安排
while (n--)
{
if (x != 6 && x != 7)
a += 250;
x++;
if (x == 8)
x = 1;
}
cout << a;
return 0;
}三角函数
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
int a, b, c,min1,max1;
cin >> a >> b >> c;
min1 = min(c, min(a, b));
max1 = max(c, max(a, b));
//直角三角形 最小锐角的sin值 必定是 最小边/最大边
for (int i = 2; i <= min1; i++) //找因数,消去。
{
if (min1%i == 0 && max1%i == 0)
{
min1 = min1 / i;
max1 = max1 / i;
}
}
cout << min1 << "/" << max1;
return 0;
}
ABC
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string a;
int A[3];
for (int i = 0; i < 3; i++)
{
cin >> A[i];
}
cin >> a;
sort(A, A + 3);
for (int i = 0; i < 3; i++)
{
cout << A[a[i] - 'A']<<" ";
}
return 0;
}边栏推荐
- Unity3d best practices: folder structure and source control
- 522. 最长特殊序列 II / 剑指 Offer II 101. 分割等和子集
- Hyperledger Fabric 2. X custom smart contract
- Use GCC to generate an abstract syntax tree "ast" and dump it to Dot file and visualization
- I want to buy fixed income + products, but I don't know what its main investment is. Does anyone know?
- AutoCAD - line width setting
- ThreadLocal之强、弱、软、虚引用
- Why can't the start method be called repeatedly? But the run method can?
- Gin general logging Middleware
- Admixture usage document Cookbook
猜你喜欢

The global chip market may stagnate, and China's chip expansion accelerates to improve its self-sufficiency rate against the trend

Interpretation of new version features of PostgreSQL 15 (including live Q & A and PPT data summary)

AI begets the moon, and thousands of miles share the literary heart

Professor huangxutao, a great master in CV field, was born at the age of 86. UIUC specially set up a doctoral scholarship to encourage cutting-edge students

Unity3d best practices: folder structure and source control

阅读别人的代码,是一种怎样的体验

Pisa-Proxy 之 SQL 解析实践
![[xman2018 qualifying] pass](/img/eb/7bf04941a96e9522e2b93859266cf2.png)
[xman2018 qualifying] pass
![[microservices sentinel] hotspot rules | authorization rules | cluster flow control | machine list](/img/42/efebf981888704b3ad42d7d4404aa7.png)
[microservices sentinel] hotspot rules | authorization rules | cluster flow control | machine list

How to select cross-border e-commerce multi merchant system
随机推荐
[xman2018 qualifying] pass
Jupiter core error
CentOS8-postgresql初始化时报错:initdb: error: invalid locale settings; check LANG and LC_* environment
CNN convolutional neural network (the easiest to understand version in History)
我想買固收+產品,但是不了解它主要投資哪些方面,有人知道嗎?
Computer screen splitting method
[advanced mathematics] from normal vector to surface integral of the second kind
Handling methods for NVIDIA deepstream running delay, jamming and crash
Je veux acheter des produits à revenu fixe + mais je ne sais pas quels sont ses principaux investissements.
Interpretation of new version features of PostgreSQL 15 (including live Q & A and PPT data summary)
Programming skills: script scheduling
Teach you how to realize pynq-z2 bar code recognition
Maximum profit of stock (offer 63)
洛谷_P1008 [NOIP1998 普及组] 三连击_枚举
volatile与JMM
At a time of oversupply of chips, China, the largest importer, continued to reduce imports, and the United States panicked
Talk about redis transactions
PR second training notes
Admixture usage document Cookbook
How QT sets some areas to be transparent in the background image