PAT (Basic) 1016~1020
来源:互联网 发布:linux 查看vnc服务 编辑:程序博客网 时间:2024/04/29 05:23
1016. 部分A+B (15)
#include <iostream>#include <string>using namespace std;int main(){string a, b;int da, db;int pa = 0, pb = 0;cin >> a >> da >> b >> db;int len1 = a.length();int len2 = b.length();for (int i = 0; i < len1; i++){if (a[i] - '0' == da){pa *= 10;pa += da;}}for (int i = 0; i < len2; i++){if (b[i] - '0' == db){pb *= 10;pb += db;}}cout << pa + pb << endl;return 0;}
1017. A除以B (20)
#include <iostream>#include <string>#include <vector>using namespace std;int main(){string a;int b;cin >> a >> b;vector<int> q;if (a.length() == 1){if (a[0] - '0' < b){cout << "0 " << a[0] - '0' << endl;}else if (a[0] - '0' >= b){cout << "1 " << a[0] - '0' - b << endl;}}else{int tmpa = (a[0] - '0') * 10 + a[1] - '0';q.push_back(tmpa / b);int tmpr = tmpa % b;for (int i = 2; i < a.length(); i++){tmpa = tmpr * 10 + a[i] - '0';q.push_back(tmpa / b);tmpr = tmpa % b;}vector<int> ::iterator it;for (it = q.begin(); it != q.end(); ++it)cout << *it;cout << " " << tmpr << endl;}return 0;}
1018. 锤子剪刀布 (20)
#include <iostream>#include <vector>using namespace std;int main(){int n;cin >> n;char c1, c2;int win = 0, tie = 0, fail = 0;int winc1 = 0, winj1 = 0, winb1 = 0;int winc2 = 0, winj2 = 0, winb2 = 0;for (int i = 0; i < n; i++){cin >> c1 >> c2;if (c1 == c2){tie++;}else if (c1 == 'C' && c2 == 'J'){win++;winc1++;}else if (c1 == 'C' && c2 == 'B'){fail++;winb2++;}else if (c1 == 'J' && c2 == 'C'){fail++;winc2++;}else if (c1 == 'J' && c2 == 'B'){win++;winj1++;}else if (c1 == 'B' && c2 == 'C'){win++;winb1++;}else if (c1 == 'B' && c2 == 'J'){fail++;winj2++;}}cout << win << " " << tie << " " << fail << endl;cout << fail << " " << tie << " " << win << endl;if (winb1 >= winc1 && winb1 >= winj1)cout << "B";else if (winc1 > winb1 && winc1 >= winj1)cout << "C";else if (winj1 > winb1 && winj1 > winc1)cout << "J";cout << " ";if (winb2 >= winc2 && winb2 >= winj2)cout << "B";else if (winc2 > winb2 && winc2 > winj2)cout << "C";else if (winj2 > winb2 && winj2 > winc2)cout << "J";cout << endl;return 0;}
1019. 数字黑洞 (20)
同PAT-A-1069. The Black Hole of Numbers (20) 见:http://blog.csdn.net/hale1007/article/details/202513971020. 月饼 (25)
同PAT-A-1070. Mooncake (25) 见:http://blog.csdn.net/hale1007/article/details/20455225
0 0
- PAT (Basic) 1016~1020
- PAT BASIC 1020 月饼
- PAT basic 1020
- PAT Basic 1020
- pat basic level 1016
- PAT Basic 1016
- PAT(basic) 1020 : 月饼问题
- 浙大 pat Basic Level 1020
- 浙大 pat Basic Level 1016
- PAT (Basic Level) Practise-1016
- PAT Basic
- Pat(Basic Level)Practice--1020(月饼)
- pat 1070 (同basic level 1020)
- 浙大PAT basic level 解题1016-10120
- PAT basic 1016 :部分A+B
- PAT BASIC 1016 部分A+B
- PAT (Basic Level) Practise
- PAT Basic 1001
- Struts2标签<s:set>的值相加操作
- iOS中如何使用表格
- 数字游戏
- 求大神指教,ios应用发布到appstore遇到了问题
- URAL 1297 Palindrome
- PAT (Basic) 1016~1020
- 算法竞赛入门经典2-6调和级数
- python - warnings
- 2014年,珍惜时间、好好把握!
- Java并发之BlockingQueue
- lake counting
- 大数据量高并发的数据库优化
- 基于PC104接口(ISA接口)的FPGA外围电路扩展板调试经验。
- Minumum Scalar Product