![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PTA c++
YCH带带我
嘤嘤嘤
展开
-
第四题 解析式表达式 北邮机试
用双栈实现表达式,与之前不同的是加入了单目运算符,用c++实现可能麻烦了些。当然,我写的不一定全部样例都过,发现还请指正。原创 2023-02-20 19:49:40 · 190 阅读 · 0 评论 -
7-3 冒泡法排序 (20分)
复习用#include<iostream>using namespace std;int main(){ int *array; int n, m; scanf("%d %d", &n, &m); array = new int[n+1]; for(int i = 0; i < n; i++) scanf("%d", &array[i]); for(int i = 0; i < m; i+原创 2020-12-11 17:56:11 · 732 阅读 · 0 评论 -
7-2 一元多项式的乘法与加法运算 (20分)
7-2 一元多项式的乘法与加法运算 (20分)设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。输入样例:4 3 4 -5 2 6 1 -2 03 5 20 -7 4 3 1输出样例:15原创 2020-12-11 17:25:24 · 65 阅读 · 0 评论 -
简单的字符串匹配
#include <iostream>using namespace std;int Find_str(char *str, char *s){ char *first = str, *second = s; while(*first != '\0') { cout << *first << " " << *second << endl; if(*first == *second)原创 2020-12-10 21:39:32 · 122 阅读 · 0 评论 -
快速排序
#include <iostream>using namespace std;int Partition(int *array, int start, int finish){ int key = array[start]; while(start < finish) { while(start < finish && array[finish] > key) finish--; array[st原创 2020-12-10 21:21:03 · 60 阅读 · 0 评论 -
7-11 公路村村通 (30分)
#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;typedef struct Hamlet{ int is_true; int parent; int pay;};Hamlet *citys;int ** data;void Init_citys_data(int N){ for(int i = 0; i < N + 2; i++) {原创 2020-11-23 17:16:42 · 242 阅读 · 0 评论 -
7-10 旅游规划 (25分)
#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;typedef struct City{ int is_true;//是否加入序列 int len;//初点到每个城市的长度 int pay;//初点到每个城市的费用;};typedef struct Data // 用矩阵表示每个城市之间的距离和费用{ int len; int pay;};City *c原创 2020-11-22 21:48:29 · 387 阅读 · 0 评论 -
7-8 修理牧场 (25分)
#include<bits/stdc++.h>using namespace std;int find_min(vector<int> &part, int x){ for(int i = part.size()-1; i >= 0; i--) { if(x <= part[i]) return i; } return 0;}int main(){ int N, x, su原创 2020-11-22 21:48:00 · 385 阅读 · 0 评论 -
7-7 Windows消息队列 (25分)
#include<bits/stdc++.h>using namespace std;typedef struct LNode{ int data; char name[12]; struct LNode *next; bool operator < (const LNode & a) const { return data > a.data; }} LNode;priority_queue <L原创 2020-11-22 21:47:16 · 307 阅读 · 0 评论 -
7-6 银行排队问题之单队列多窗口加VIP服务 (30分)
#include <algorithm>#include<iostream>#include<bits/stdc++.h>using namespace std;struct List{ int start_time;//头指针计总分等待时间 int end_time;//头指针计最长等待时间 int wait_time;//代表服务了多少人 int VIP;//队列头表示是否为VIP序列 struct List *nex原创 2020-11-22 21:46:15 · 638 阅读 · 0 评论 -
7-3 银行业务队列简单模拟 (25分)
num = input()num_list = num.split(" ")for i in range(0, len(num_list)): num_list[i] = int(num_list[i])List, List1, List2 = [], [], []Range = num_list.pop(0)j = 0for i in num_list: if i % 2 == 1: List1.append(i) if i % 2 == 0:原创 2020-11-22 21:44:16 · 941 阅读 · 0 评论 -
7-5 银行排队问题之单队列多窗口服务 (25分)
#include <algorithm>#include<iostream>using namespace std;struct List{ int start_time;//头指针计总分等待时间 int end_time;//头指针计最长等待时间 int wait_time;//代表服务了多少人 struct List *next;};void Insert_List(List *head, List *tail, List *L){.原创 2020-11-22 21:41:48 · 352 阅读 · 0 评论