PAT b1036-b1040题解
来源:互联网 发布:php jsonp callback 编辑:程序博客网 时间:2024/06/06 20:24
1、b1036
#include <cstdio>int main(){int col, row;char symbol;scanf("%d %c", &col, &symbol);if(col % 2 == 0){row = col / 2;}if(col % 2 == 1){row = col / 2 + 1;}for(int i = 0; i < col; i++){printf("%c", symbol);}printf("\n");for(int i = 0; i < row - 2; i++){printf("%c", symbol);for(int i = 0; i < col -2; i++){printf(" ");}printf("%c", symbol);printf("\n");} for(int i = 0; i < col; i++){printf("%c", symbol);}return 0;}
2、b1037
#include <cstdio>const int Gallon = 17 * 29;const int Sickle = 29;int main(){int a1, b1, c1;int a2, b2, c2;scanf("%d.%d.%d %d.%d.%d", &a1, &b1, &c1, &a2, &b2, &c2);int price = a1 * Gallon + b1 * Sickle + c1;int money = a2 * Gallon + b2 * Sickle + c2;int change = money - price;if(change < 0){printf("-");change = -change; }printf("%d.%d.%d\n", change / Gallon, change % Gallon / Sickle, change % Sickle);return 0;}
3、b1038
#include <cstdio>int grade[101] = {0};int main(){int n;scanf("%d", &n);for(int i = 0; i < n; i++){int score;scanf("%d", &score);grade[score]++;}int m;scanf("%d", &m);for(int i = 0; i < m; i++){int score;scanf("%d", &score);if(i == m -1){printf("%d", grade[score]);}else{printf("%d ", grade[score]);}}return 0;}
4、b1039
#include <cstdio>#include <cstring>int hashTable[128] = {0};char str1[1010];char str2[1010];int count = 0;int main(){gets(str1);int len1 = strlen(str1);for(int i = 0; i < len1; i++){hashTable[str1[i]]++;}gets(str2);int len2 = strlen(str2);for(int i = 0; i < len2; i++){hashTable[str2[i]]--;if(hashTable[str2[i]] < 0){count++;}}if(!count){printf("Yes %d", len1 -len2);}else{printf("No %d", count);}return 0;}
5、b1040
#include <cstdio>#include <cstring>const int MAXN = 100010;const int MOD = 1000000007;char str[MAXN];int leftNumP[MAXN] = {0};int main(){gets(str);int len = strlen(str);for(int i = 0; i < len; i++){if(i > 0){leftNumP[i] = leftNumP[i - 1];}if(str[i] == 'P'){leftNumP[i]++;}}int ans = 0, rightNumT = 0;for(int i = len - 1; i >= 0; i--){if(str[i] == 'T'){rightNumT++;}else if(str[i] == 'A'){ans = (ans + leftNumP[i] * rightNumT) % MOD;}}printf("%d", ans);return 0;}
阅读全文
1 0
- PAT b1036-b1040题解
- PAT B1040
- PAT B1036
- PAT B1036
- 浙大 PAT b1040
- 浙大 PAT b1036
- PAT-B1040. 有几个PAT
- PAT B1040. 有几个PAT
- 数学问题--PAT. B1040 & A1093
- PAT乙级练习题B1040. 有几个PAT
- B1036
- B1040. 有几个PAT(25)
- PAT B1036.跟奥巴马一起编程
- B1040. 有几个PAT(25)。。。解题思路值得学习
- PAT乙级练习题B1036. 跟奥巴马一起编程
- PAT---B1036. 跟奥巴马一起编程(15)
- PAT B1036. 跟奥巴马一起编程(15)
- PAT 1001-1010 题解
- 反射机制
- Java你该知道的——String类
- 嵌入式学习20170710
- 【iOS】基于Realm数据库的记账软件--Realm数据库(一)
- starUML使用教程
- PAT b1036-b1040题解
- 04.13 三剑客之老二sed命令详解
- springboot1.1.0自定义静态文件配置bug
- SLAM学习——非线性优化
- 【51Nod】1035 最长的循环节
- scala系列知识点总结(变量与普通函数)
- HDU 3533 BFS
- 1-100之间的所有素数的和如何在JSP页面实现 代码如下
- pk10彩票统计代码分享