当前位置:网站首页>L1-025 positive integer a+b (15 points)
L1-025 positive integer a+b (15 points)
2022-07-04 07:29:00 【Inter personal liabilities^】
L1-025 Positive integer A+B (15 branch )
The goal of the question is very simple , It's two positive integers A
and B
And , among A
and B
It's all in the range [1,1000]. A little bit of a hassle , The input is not guaranteed to be two positive integers .
Input format :
Type in on a line to give A
and B
, They are separated by spaces . The problem is A
and B
It doesn't have to be a positive integer , Sometimes it can be out of range numbers 、 negative 、 A real number with a decimal point 、 It's even a mess of code .
Be careful : Let's put... In the input 1 A space is taken as A
and B
Separation of . Make sure that there is at least one space for the question , also B
It's not an empty string .
Output format :
If the input is really two positive integers , According to the format A + B = and
Output . If an input is not satisfactory , Output at corresponding position ?
, Obviously at this time and also ?
.
sample input 1:
123 456
sample output 1:
123 + 456 = 579
sample input 2:
22. 18
sample output 2:
? + 18 = ?
sample input 3:
-100 blabla bla...33
sample output 3:
? + ? = ?
test 3: Similar to the third example , There may be more than two data entered , When the input data exceeds two data , You should directly output the results that are all question marks
test 5: The upper limit of the number is 1000, There are requirements for the topic , But when typing , I didn't input as required, so I need to judge
test 6: The lower limit of the number is 1, And testing 5 identical
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=100010;
int main()
{
string a;
getline(cin, a);
bool flaga = false, flagb = false;
int aa = 0, bb = 0;
int flag = 0;
for(int i = 0; i < a.size(); i ++ )
{
if(a[i] == ' ') flag = i;
if(flag > 0) break;
}
for(int i = 0; i < flag; i ++ )
{
aa = aa * 10 + (a[i] - '0');
if(a[i] < '0' || a[i] > '9')
{
flaga = true;
break;
}
}
int flag1 = 0;
for(int i = flag + 1; i < a.size(); i ++ )
{
bb = bb * 10 + (a[i] - '0');
if(a[i] < '0' || a[i] > '9')
{
flagb = true;
break;
}
}
if(aa > 1000 || aa < 1) flaga = true;
if(bb > 1000 || bb < 1) flagb = true;
if(flaga) cout << '?' << ' ';
else cout << aa << ' ';
cout << '+' << ' ';
if(flagb) cout << '?' << ' ';
else cout << bb << ' ';
cout << '=' << ' ';
if(flaga || flagb) cout << '?';
else cout << aa + bb;
return 0;
}
边栏推荐
- Crawler (III) crawling house prices in Tianjin
- socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
- Unity 从Inspector界面打开资源管理器选择并记录文件路径
- The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D
- Zephyr 学习笔记1,threads
- 2022-021ARTS:下半年开始
- Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
- System architecture design of circle of friends
- Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
- Guoguo took you to write a linked list, and the primary school students said it was good after reading it
猜你喜欢
Chain ide -- the infrastructure of the metauniverse
[Mori city] random talk on GIS data (I)
The IP bound to the socket is inaddr_ The meaning of any htonl (inaddr_any) (0.0.0.0 all addresses, uncertain addresses, arbitrary addresses)
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
Status of the thread
win10微软拼音输入法输入文字时候下方不出现中文提示
节点基础~节点操作
Master-slave replication principle of MySQL database
Transition technology from IPv4 to IPv6
随机推荐
Handwritten easy version flexible JS and source code analysis
大学阶段总结
Solution of running crash caused by node error
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
Rhcsa the next day
rapidjson读写json文件
Experience installing VMware esxi 6.7 under VMware Workstation 16
Zabbix agent主动模式的实现
Master-slave replication principle of MySQL database
Summary of MySQL common judgment functions!! Have you used it
What is the use of cloud redis? How to use cloud redis?
Xcode 14之大变化详细介绍
Introduction to sap commerce cloud B2B organization function
MySQL中的文本处理函数整理,收藏速查
Boast about Devops
Data double write consistency between redis and MySQL
Computer connects raspberry pie remotely through putty
A new understanding of how to encrypt industrial computers: host reinforcement application
MySQL 数据库 - 函数 约束 多表查询 事务
Literature collation and thesis reading methods