C/C++
文章平均质量分 73
世界第一可爱ɞ
这个作者很懒,什么都没留下…
展开
-
C++编程规范总结
无原创 2022-08-13 14:33:11 · 341 阅读 · 2 评论 -
计算机网络部分面试题
1.TCP和UDP的区别用户数据报协议 UDP(User Datagram Protocol) 是无连接的,尽最大可能交付,没有拥塞控制,面向报文(对于应用程序传下来的报文不合并也不拆分,只是添加UDP首部),支持一对一、一对多、多对一和多对多的交互通信。传输控制协议 TCP(Transmission Control Protocol) 是面向连接的,提供可靠交付,有流量控制,拥塞控制,提供全双工通信,面向字节流(把应用层传下来的报文看成字节流,把字节流组织成大小不等的数据块),每一条 TCP 连接只能原创 2022-02-19 12:53:06 · 1177 阅读 · 0 评论 -
操作系统部分面试题
进程和线程间的通信方式 Linux进程:管道、有名管道、信号、信号量、共享内存、消息队列、套接字 Linux线程:互斥体、信号量、条件变量 Windows进程:管道、共享内存、消息队列、信号量、套接字 Windows线程:临界区、互斥量、信号量、事件 死锁产生的原因和死锁的条件 原因:系统资源的竞争、进程推进顺序非法 条件:互斥条件、不剥夺条件、请求和保持条件、循环等待条件 如何采用单线程处理高并发 采取I/O复用来提高单线程处理多请求的能力(epoll和select)..原创 2022-02-18 16:08:04 · 247 阅读 · 0 评论 -
C/C++面试/笔试题2022
多态的实现 在基类的函数前加上virtual关键字,在派生类中重写该函数,运行时将会根据对象的实际类型来调用相应的函数。 如果对象类型是派生类,就调用派生类的函数;如果对象类型是基类,就调用基类的函数,此为多态的表现; Cpp四种强制类型转换 const_cast:从字面意思上就可以理解,去除变量的const属性。 static_cast:静态类型转换,一般用于基本类型间的转换,如char->int dynamic_cast:动态转换,同于多态之间的类型转换 reinterp..原创 2022-02-21 11:46:01 · 1706 阅读 · 0 评论 -
PAT甲级1098 Insertion or Heap Sort (25 分)
1098 Insertion or Heap Sort (25 分)According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the locatio...原创 2022-01-20 11:56:35 · 637 阅读 · 0 评论 -
PAT甲级1097 Deduplication on a Linked List (25 分)
1097 Deduplication on a Linked List (25 分)Given a singly linked listLwith integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each valueK, only the first node of which the value or absolute valu...原创 2022-01-19 10:46:08 · 189 阅读 · 0 评论 -
PAT甲级1096 Consecutive Factors (20 分)
1096 Consecutive Factors (20 分)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are原创 2022-01-17 11:50:11 · 181 阅读 · 0 评论 -
PAT甲级1094 The Largest Generation (25 分)
1094 The Largest Generation (25 分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input Specification:Each原创 2022-01-13 11:39:08 · 74 阅读 · 0 评论 -
PAT甲级1093 Count PAT‘s (25 分)
1093 Count PAT's (25 分)The stringAPPAPTcontains twoPAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now given any string, you are suppo...原创 2022-01-12 10:43:11 · 92 阅读 · 0 评论 -
PAT甲级1092 To Buy or Not to Buy (20 分)
1092 To Buy or Not to Buy (20 分)Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in whole原创 2022-01-11 10:44:56 · 136 阅读 · 0 评论 -
PAT甲级1090 Highest Price in Supply Chain (25 分)
1090 Highest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys原创 2022-01-08 15:11:16 · 312 阅读 · 0 评论 -
PAT甲级1089 Insert or Merge (25 分)
1089 Insert or Merge (25 分)According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belo.原创 2022-01-07 11:41:58 · 330 阅读 · 0 评论 -
PAT甲级1088 Rational Arithmetic (20 分)
1088 Rational Arithmetic (20 分)For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test case, which gives in one原创 2022-01-06 11:55:10 · 198 阅读 · 0 评论 -
PAT甲级1087 All Roads Lead to Rome (30 分)
1087 All Roads Lead to Rome (30 分)Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each input file contains原创 2022-01-05 16:13:13 · 410 阅读 · 0 评论 -
PAT甲级1085 Perfect Sequence (25 分)
1085 Perfect Sequence (25 分)Given a sequence of positive integers and another positive integerp. The sequence is said to be aperfect sequenceifM≤m×pwhereMandmare the maximum and minimum numbers in the sequence, respectively.Now given a sequenc...原创 2022-01-03 14:46:41 · 525 阅读 · 0 评论 -
PAT甲级1084 Broken Keyboard (20 分)
1084 Broken Keyboard (20 分)On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to type, and the string that原创 2022-01-02 15:46:30 · 151 阅读 · 0 评论 -
PAT甲级1083 List Grades (25 分)
1083 List Grades (25 分)Given a list ofNstudent records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.Input..原创 2021-09-17 17:36:44 · 277 阅读 · 0 评论 -
PAT甲级1081 Rational Sum (20 分)
1081 Rational Sum (20 分)GivenNrational numbers in the formnumerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integerN(≤100), followed in the...原创 2021-09-15 18:15:38 · 82 阅读 · 0 评论 -
PAT甲级1080 Graduate Admission (30 分)
1080 Graduate Admission (30 分)It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.Each applic原创 2021-09-14 17:49:09 · 55 阅读 · 0 评论 -
PAT甲级1079 Total Sales of Supply Chain (25 分)
1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys pr原创 2021-09-13 18:56:22 · 70 阅读 · 0 评论 -
PAT甲级1078 Hashing (25 分)
1078 Hashing (25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to beH(key)=key%TSizewhereTSizeis the maximum size o...原创 2021-09-09 18:36:30 · 93 阅读 · 0 评论 -
PAT甲级1077 Kuchiguse (20 分)
1077 Kuchiguse (20 分)The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggera原创 2021-09-08 18:14:11 · 75 阅读 · 0 评论 -
PAT甲级1076 Forwards on Weibo (30 分)
1076 Forwards on Weibo (30 分)Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post on Weib原创 2021-09-07 09:35:56 · 64 阅读 · 0 评论 -
PAT甲级1075 PAT Judge (25 分)
1075 PAT Judge (25 分)The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file contains one test case. For each ca原创 2021-09-06 17:52:05 · 83 阅读 · 0 评论 -
PAT甲级1074 Reversing Linked List (25 分)
1074 Reversing Linked List (25 分)Given a constantKand a singly linked listL, you are supposed to reverse the links of everyKelements onL. For example, givenLbeing 1→2→3→4→5→6, ifK=3, then you must output 3→2→1→6→5→4; ifK=4, you must output 4→3→...原创 2021-09-05 19:41:11 · 75 阅读 · 0 评论 -
PAT甲级1073 Scientific Notation (20 分)
1073 Scientific Notation (20 分)Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that the integer portion has exactly原创 2021-09-04 13:15:33 · 69 阅读 · 0 评论 -
PAT甲级1072 Gas Station (30 分)
1072 Gas Station (30 分)A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range.原创 2021-09-03 12:35:15 · 105 阅读 · 0 评论 -
C++函数isalnum(),tolower()
isalnum():判断一个字符是否是字母或者(十进制)数字,若为字母或者数字,则返回True(非0值),否者返回False(0)tolower():将大写转换成小写,A->a. 小写和非字母不变。...原创 2021-08-31 20:37:44 · 152 阅读 · 0 评论 -
PAT甲级1071 Speech Patterns (25 分)
1071 Speech Patterns (25 分)People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can help to narrow down a speaker's identity, which is usefu原创 2021-08-31 20:34:36 · 119 阅读 · 0 评论 -
PAT甲级 1070 Mooncake (25 分)
1070 Mooncake (25 分)Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now given the inventory amounts and th原创 2021-08-31 07:45:53 · 84 阅读 · 0 评论 -
PAT甲级 1069 The Black Hole of Numbers (20 分)
1069 The Black Hole of Numbers (20 分)For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by taking the second numb原创 2021-08-29 16:15:30 · 49 阅读 · 0 评论 -
PAT甲级1067 Sort with Swap(0, i) (25 分)
1067 Sort with Swap(0, i) (25 分)Given any permutation of the numbers {0, 1, 2,...,N−1}, it is easy to sort them in increasing order. But what ifSwap(0, *)is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply t...原创 2021-08-27 07:54:01 · 69 阅读 · 0 评论 -
PAT甲级1068 Find More Coins (30 分)
1068 Find More Coins (30 分)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requir原创 2021-08-27 07:52:13 · 198 阅读 · 0 评论 -
PAT甲级 1066 Root of AVL Tree (25 分)
1066 Root of AVL Tree (25 分)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this prop原创 2021-08-25 09:19:34 · 73 阅读 · 0 评论 -
PAT甲级1065 A+B and C (64bit) (20 分)
1065 A+B and C (64bit) (20 分)Given three integersA,BandCin (−263,263), you are supposed to tell whetherA+B>C.Input Specification:The first line of the input gives the positive number of test cases,T(≤10). ThenTtest cases follow, each con...原创 2021-08-24 07:54:07 · 78 阅读 · 0 评论 -
PAT甲级1064 Complete Binary Search Tree (30 分)
1064 Complete Binary Search Tree (30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node原创 2021-08-23 07:44:20 · 84 阅读 · 0 评论 -
PAT甲级1063 Set Similarity (25 分)
1063 Set Similarity (25 分)Given two sets of integers, the similarity of the sets is defined to beNc/Nt×100%, whereNcis the number of distinct common numbers shared by the two sets, andNtis the total number of distinct numbers in the two sets. Yo...原创 2021-08-21 09:46:57 · 74 阅读 · 0 评论 -
PAT甲级1062 Talent and Virtue (25 分)
1062 Talent and Virtue (25 分)About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a "sage(圣人)";原创 2021-08-19 08:17:22 · 71 阅读 · 0 评论 -
PAT甲级1061 Dating (20 分)
1061 Dating (20 分)Sherlock Holmes received a note with some strange strings:Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the cod...原创 2021-08-18 08:53:40 · 72 阅读 · 0 评论