![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
shadowannarock
Life runs on code.
展开
-
[PAT][Basic level]1087
KeyWords: std::set ; ordered;no-repeat;AC CODE:#include <iostream>using namespace std;#define MAXN 30000+1int main(){ //freopen("sample_input.txt","r",stdin); int flag[MAXN]={0}; int N; cin>>N; int cnt = 0; for(原创 2021-06-21 21:24:13 · 103 阅读 · 0 评论 -
[PAT][Basic Level Practice]Problem1089
Solution:已知 N 名玩家中有 2 人扮演狼人角色,有 2人说的不是实话,有狼人撒谎但并不是所有狼人都在撒谎。要求你找出扮演狼人角色的是哪几号玩家?——》说谎话的人(liar):一个是狼人(wolf);一个是好人(man)如果有解,在一行中按递增顺序输出 2 个狼人的编号,其间以空格分隔,行首尾不得有多余空格。如果解不唯一,则输出最小序列解 ——即对于两个序列 A=a[1],…,a[M] 和 B=b[1],…,b[M],若存在 0≤k<M 使得 a[i]=b[i](i≤k)原创 2021-06-20 23:28:44 · 225 阅读 · 0 评论 -
[PAT][Basic Level]1090
KEYWORDS: std :: map <int ,vector > mymap ;(图,构造int型 和 int型一维数组的映射,一 对 多)mymap[item1].push_back(item2);std::vector V; std::vector::iterator ;vector.begin();vector.end();for(iterator = vector.begin() ; iterator != vector; iterator ++)AC CODE:原创 2021-06-20 22:21:10 · 120 阅读 · 0 评论 -
[PAT][Basic level]1091
KeyWords:to_string();string.substr();format outputAC CODE:#include <iostream>#include <cstring>#include <string>using namespace std;int main(){ //freopen("sample_input.txt","r",stdin); int M; cin>>M; while(原创 2021-06-20 14:10:06 · 70 阅读 · 0 评论 -
[PAT][Basic level]1095
Keywords:string ;string.substr(pos_start,lenth);std::stoi(string,NULL,10);sort();Not AC CODE:(3/5)#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;struct student{ char num[14];原创 2021-06-19 18:45:49 · 72 阅读 · 0 评论 -
[PAT][Basic level]1094
Keywords:string ;str.size();str.substr(pos_begin,lenth);sstream;istringstream is; is>>num;NOT AC CODE:(3/5)#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <sst原创 2021-06-19 16:21:43 · 60 阅读 · 0 评论 -
[PAT][Basic Level]1057
KeyWords:count_zero_binary :num | (num+1)count_one_binary :num & (num -1)num >>1;AC CODE:#include <iostream>#include <cstdio>#include <cstdlib>#define M 100000+1#include <cstring>using namespace std;int main(){原创 2021-06-17 21:03:44 · 52 阅读 · 0 评论 -
[PAT][Basic Level]1054
KeyWords:sscanf(str_input,"%lf",&temp);sprintf(str_cmp,"%.2f",temp);Not AC code:(4/5)#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ int N; int count = 0;原创 2021-06-17 16:51:54 · 59 阅读 · 0 评论 -
[PAT][Basic Level]1052
Keywords: vector<vector >sign_map ;two dimensional vector; vector str_input; string.size();string.length();string.substr(pos_start,pos_end); sign_map.push_back();AC CODE:#include <iostream>#include <vector>using namespace std;int原创 2021-06-17 14:58:55 · 48 阅读 · 0 评论 -
[PAT][Basic Level]1051
Keywords:double ,float,AC CODE:#include <iostream>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;int main(){ double r1,p1,r2,p2; cin>>r1>>p1>>r2>>p2; double a1,b1,a2,b2;原创 2021-06-16 22:56:09 · 47 阅读 · 0 评论 -
[PAT][Basic Level]1050
Keywords:Dynamic allocation and release of two dimensional array;sort() belongs to NOT AC CODE:(3/5). segmentation fault#include <iostream>#include <cstdio>#include <cstdlib>#include <iomanip>#include <cmath>#include &l原创 2021-06-16 22:01:09 · 48 阅读 · 0 评论 -
[PAT][Basic Level]1049
Time Limited CODE:#include <iostream>#include <cstdio>#include <cstdlib>#include <iomanip>using namespace std;int main(){ int n; cin>>n; double sum = 0; double temp = 0; double *num_input ; num_input = (double *原创 2021-06-16 19:24:01 · 47 阅读 · 0 评论 -
[PAT][Basic Level]1048
NOT AC CODE:```cpp#include #include #include #include using namespace std;#define M 100+1int main(){char strA[M];char strB[M];char str_output[M+10];cin>>strA>>strB;char to_char[13]={‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘J’,‘Q’,原创 2021-06-08 21:17:36 · 68 阅读 · 0 评论 -
[PAT][Basic Level]1035
KeyWords:Insertion_sort(*array,length);Merge_sort(*array,length);AC CODE:#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>using namespace std;void Inser原创 2021-06-07 22:26:22 · 44 阅读 · 0 评论 -
[PAT][Basic level]1034
KeyWords:GCD(greatest common divisor);#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;int gcd(int a,int b){ return a%b?gcd(b,a%b):b;}int main(){ int m , n; cin>>m>>n; cout原创 2021-06-07 17:51:05 · 81 阅读 · 0 评论 -
[PAT][basic Level]1031
AC CODE:#include <cstdio>#include <iostream>#include <cstdlib>#include <cstring>using namespace std;int main(){ int n; cin>>n; char num[18]; int temp = 0; int sum = 0; int quan[17]={7,9,10,5原创 2021-06-06 16:55:55 · 43 阅读 · 0 评论 -
[PAT][Basic Level]1030
Warning: sometime time limitedAC CODE:#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;int main(){ long long n,p; cin >> n>>p; lon原创 2021-06-06 16:23:27 · 44 阅读 · 0 评论 -
[PAT][Basic Level]1029
AC CODE:no problem(5/5)#include <cstdio>#include <iostream>#include <cstdlib>#include <cstring>using namespace std;int main(){ char str1[81],str2[82]; cin>>str1>>str2; int flag[128]; memset(f原创 2021-06-06 15:30:39 · 43 阅读 · 0 评论 -
[PAT][Basic Level] 1026
AC CODE:WARNING:omititng decimal fractions smaller than 0.5 and counting all others(四舍五入)#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;#define CLK_TCK 100int main(){ int c原创 2021-06-06 10:43:57 · 82 阅读 · 0 评论 -
[PAT][Basic Level]1024
NOT AC CODE :(6/7)One Problem:#include <cstdio>#include <iostream>#include <cstdlib>#include <cstring>using namespace std;int main(){ char num_input[10000]; cin>>num_input; int index = 0 ; bool fla原创 2021-06-05 17:50:59 · 51 阅读 · 0 评论 -
[PAT][Basic Level]1023
NOT AC CODE(3/5):#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;int main(){ int num[10]; memset(num,0,sizeof(int)*10); int len = 0;原创 2021-06-05 16:51:13 · 52 阅读 · 0 评论 -
[PAT][Basic Level] 1022 code review
NOT AC CODE:(5/6)One problem#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <iomanip>using namespace std;void PrintBase(int number , int base){ int stor原创 2021-06-05 16:30:46 · 52 阅读 · 0 评论 -
[PAT][Basic Level]1020 code review
AC CODE:#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <iomanip>#include <cmath>#include <cstring>using namespace std;struct mooncake{ double store; double total原创 2021-06-05 14:50:27 · 53 阅读 · 0 评论 -
[PAT][Basic Level]1019 done
AC CODE:#include <iostream>#include <algorithm>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;int ArrayToNumber(char *ch);char * NumberToArray(int number);bool cmp(cha原创 2021-06-05 13:55:24 · 55 阅读 · 0 评论 -
[PAT][Basic level]1018code review
NOT AC CODE:2 problems to be resolved(4/6)#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>using namespace std;void print(int count_c,int count_j,int count_b ){ if( count_c > count_j){原创 2021-06-05 12:58:32 · 53 阅读 · 0 评论 -
[PAT][Basic level] 1017 code review
NOT AC CODE:(2/5)#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>using namespace std;int main(){ char num[1001]; int b; char q[1001]; int r; cin>>num>>b; int su原创 2021-06-05 11:38:11 · 55 阅读 · 0 评论 -
[PAT][Basic level] 1016
aside note: the array of strings ends of ‘\0’;#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>using namespace std;int main(){ char a[10],b[10]; char d_a,d_b; cin>>a>>d_a>>原创 2021-06-05 10:45:22 · 40 阅读 · 0 评论 -
[PAT][Basic level] 1015 code review
Not AC Code:(one problem to be resolved)KeyWrods: sort();bool cmp();#include “algorithm”;the diffirence between qsort() and sort();struct;typedef (关键字替换);#include <cstdio>#include <iostream>#include <cstring>#include <iomanip>原创 2021-06-05 10:16:38 · 82 阅读 · 0 评论 -
[PAT][basic level]1014 福尔摩斯的约会
#include <cstdio>#include <iostream>#include <cstring>#include <iomanip>#include <cmath>using namespace std;int main(){ char str1[61],str2[61],str3[61],str4[61]; char week[7][4]={"MON","TUE","WED","THU","FRI","S原创 2021-06-04 18:03:58 · 38 阅读 · 0 评论 -
about<iomanip>
IO manipulators:Header providing parametric manipulators:C plus plus Reference:《iomanip》setiosflags :Set format flagsresetiosflags :Reset format flagssetbase :Set basefiled flagsetfill :Set fill charactersetprecision :Set decimal precisionset原创 2021-06-04 15:18:41 · 111 阅读 · 0 评论 -
[PAT][basic level] 1008 review
Keywords: array reverse;defination && declare of the function;pointerAC Code:#include <cstdio>#include <iostream>#include <cstdlib>#include <algorithm>using namespace std;void reverse(int *array , int Pos_start , int原创 2021-06-04 11:42:13 · 53 阅读 · 0 评论 -
[PAT][Basic level]1005 继续3*n+1猜想
issue to be resolved:segmantation faultCode:#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;bool cmp (int a,int b){ return a > b ;}int main(){.原创 2021-06-04 10:06:19 · 69 阅读 · 0 评论 -
[PAT][Basic level]Problem 1004:成绩排名 review
KeyWords:struct,malloc,sizeof,struct *,pointer#include <cstdio>#include <iostream>#include <cstdlib>using namespace std;struct student{ char name[11]; char number[11]; int score;};int main (){ int n,i=0; std::原创 2021-06-03 17:43:54 · 67 阅读 · 0 评论 -
[PAT][basic level] Problem 1003 : 我要通过!review
Pure Code:AC代码#include <iostream>#include <cstring>#include <cmath>using namespace std;int main() { int n; cin>>n; char string[100]; while(n--) { cin>>string; //std::cout << string <<" "<原创 2021-06-03 16:58:24 · 45 阅读 · 0 评论 -
about “<bits/stdc++.h>“
Main Problem:PAT(basical level) 1028Related Link:https://blog.csdn.net/qq_34451909/article/details/104752861What is it?(“bits/stdc++.h”)StackOverFlow LInk:https://stackoverflow.com/questions/25311011/how-does-include-bits-stdc-h-work-in-c/25311052#原创 2021-06-03 11:22:50 · 109 阅读 · 0 评论 -
【2021.6.3】Learning Process Record
Main Problem:PAT (Basical Level)1025KeyWords:Linked List;CurrentNode;InitList;DeleteList;InsertList;GetListLength;ReverseList;LocateElement;DestroyList;Related Link:https://blog.csdn.net/u012531536/article/details/80170893原创 2021-06-03 10:08:39 · 63 阅读 · 0 评论 -
【PTA basic level】Problem 1009 review
Keywords:arry;two dimensional arry of stings(字符串二维数组);address;the name of the arry means the first addressaside note: two dimensional arry of stings is separated by branches,whereas(but) its storage structure is continuous.#include<stdio.h>int原创 2021-05-28 20:58:37 · 57 阅读 · 0 评论 -
【PAT】1007 review
int i;for(i=0; ;) 与 for(int i=0 ; ;) 两种定义循环变量的方式的区别:the difference between int i;for(i = 0;;) and for(int i = 0;;):两种均可,前者i在for循环外部定义,则i的值在程序未结束之前就一直存在,i所占的内存空间直到程序结束时才释放;后者的i在for循环内部定义,则当for循环结束时,i所占的内存空间就被释放了。一般建议用后者的方式,因为当程序较大时,前者更占内存,这样程序在运行时CPU的负担原创 2021-05-28 16:16:13 · 51 阅读 · 0 评论 -
【2021-05-27】 Learning progress record
PAT(Basic level)-1005关联题: PAT(Basic level)-1001Key Words:卡拉兹(Callatz)猜想 ,C++ 的 STL (Standard Template Library)中 sort函数,sort函数的三个参数(RandomAccessIterator first,RandomAccessIterator last,Compare comp),sort函数的内部实现原理,quick sort,insertion sort,时间复杂度分别是多少以及为什么是原创 2021-05-27 23:34:19 · 103 阅读 · 0 评论 -
PTA7-3 求最大值及其下标(20 分)
7-3 求最大值及其下标(20 分)本题要求编写程序,找出给定的n个数中的最大值及其对应的最小下标(下标从0开始)。输入格式:输入在第一行中给出一个正整数n(1<n≤10)。第二行输入n个整数,用空格分开。输出格式:在一行中输出最大值及最大值的最小下标,中间用一个空格分开。<textarea readonly ="readonly" name ="code" class="c++"&g...原创 2018-02-27 20:40:07 · 6111 阅读 · 1 评论