![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
adrianna_xy
假如编程易懂得,那么程序员就不会热情地写出注释,也不会有得到编程的快乐。
展开
-
人口普查(20)
题目描述 某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。 这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过200岁的老人,而今天是2014年9月6日,所以超过200 岁的生日和未出生的生日都是不合理的,应该被过滤掉。 输入描述: 输入在第一行给出正整数N,取值在(0, 105];随后N行,每行给出1个人的姓原创 2016-04-11 23:06:22 · 1276 阅读 · 0 评论 -
有几个PAT(25)
#include <iostream> #include <string> //#include <vector> using namespace std; int main(){ string s; cin >> s; int len = s.size(); //三重循环超时 /* for (long i = 0; i < len; i++){ i原创 2016-04-19 15:40:22 · 524 阅读 · 0 评论 -
在霍格沃茨找零钱(20)
#include <iostream> #include <math.h> using namespace std;int main(){ long pg, ps, pk; long ag, as, ak; long diff_g, diff_s, diff_k; scanf("%ld.%ld.%ld", &pg, &ps, &pk); // cout << pg原创 2016-04-19 14:11:56 · 463 阅读 · 0 评论 -
统计同成绩学生(20)
#include <iostream> using namespace std;long grades[101] = { 0 }; long amount(int mark); int main(){ long n, k; cin >> n; int search[101]; int mark; for (int i = 0; i < n; i++){原创 2016-04-19 13:21:41 · 339 阅读 · 0 评论 -
跟奥巴马一起编程(15)
#include <iostream> #include <math.h> using namespace std;int main(){ int n; char c; cin >> n >> c; int col = n; int k; int row = floor((double)col / 2 + 0.5); for (int i =原创 2016-04-19 00:24:45 · 484 阅读 · 0 评论 -
有理数四则运算(20)
这道题比较难,输出的不同条件比较多,代码是改了人家的答案,用到了stringstream,学习学习。/* 所有输出均转换为真分式形式 负号的位置,负号在括号内,不是在括号外。 (-1 1/3) 整数部分为0时不输出整数部分,真分式部分为0时也不输出 */#include <iostream> #include <stdio.h> #include <math.h> #include <sstr原创 2016-04-18 23:39:27 · 525 阅读 · 0 评论 -
旧键盘打字(20)
#include<iostream> #include<string> using namespace std; int len, len2; int main(){ bool brokenKey[257] = { false }; //ASCII码使用指定的7位或8位二进制数组合来表示128或256种可能的字符。 string suppose; string bStr;原创 2016-04-17 21:51:40 · 442 阅读 · 0 评论 -
挖掘机技术哪家强(20)
#include<cstdlib> #include<cstdio> #include<map> #include<iostream> /************************************************************************ * * Map的特点: 1、存储Key-value对 * 2、支持快速查找,查找的复杂度基本是Log(N) * 3、快原创 2016-04-16 23:08:34 · 441 阅读 · 0 评论 -
查验身份证(15)
#include <iostream> #include<string> using namespace std;int main(){ int n, mod; char id[20]; char weight[17] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 }; char checksum[11] = { '1', '0',原创 2016-04-16 21:53:00 · 392 阅读 · 0 评论 -
完美数列(25)
#include <iostream> #include <algorithm> using namespace std;int main(){ int n,p; int seq[100005]; int num=1;//记录最大数目。初始化为1; cin>>n>>p; for(int i=0;i<n;i++){ cin>>seq[i];原创 2016-04-16 20:20:15 · 449 阅读 · 0 评论 -
旧键盘 (20) (c++/python)
思路(对应解法二): 对输入1进行hash,由于所有的正确按键都应该响应,仅仅只有坏的按键不响应,那么对照hash判断输入2,对存在的字符进行标记; 那么遍历输入2一遍以后,没有被标记的字符就是有问题的坏键盘按键,顺序输出即可。解法一: (思路比较自然简单的解法)#include <iostream> #include <cstring> using namespace std; int ma原创 2016-04-16 11:39:07 · 487 阅读 · 0 评论 -
程序运行时间(15)
题目描述: 获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所 耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获 得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一个时钟打点数C1;在f原创 2016-04-11 17:05:31 · 2395 阅读 · 0 评论 -
反转链表 (25)
反转链表原创 2016-04-11 16:34:07 · 349 阅读 · 0 评论 -
插入与归并(25)
思路: 将原始序列和中间序列分别存入int 向量, 先判断是否是插入排序(若为插入,则第一个小于前一个元素的元素及之后的元素都与org相同,不同则为merge; 若为插入排序,有序排序中小于cur[next]的元素输出,再输出cur[next],再依次输出剩下的元素 若为归并排序,下一次递归,每个有序子序列有2*next个元素,用sort函数将每个子序列排序,再依次输出 #include <iost原创 2016-04-20 00:28:13 · 592 阅读 · 0 评论