题解 | #加法模拟器#

加法模拟器

https://ac.nowcoder.com/acm/problem/22007

//竖版的时候注意看题目的横线-------,刚好是7位,且右边对齐。 #include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' void solve(){ int a,b; cin>>a>>b; cout<<a<<"+"<<b<<"="<<a+b<<endl; cout<<right<<setw(7)<<a<<endl;//right是右对齐,setw(7)是宽度7位,不足在前面补空格 cout<<"+"<<right<<setw(6)<<b<<endl;//这里前面多了一个加号,所以是6位了 cout<<"-------"<<endl; cout<<right<<setw(7)<<a+b<<endl; } signed main(){ std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }

全部评论

相关推荐

喜欢喜欢喜欢:这是我见过最长最臭的简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务