![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
叫我WA
未曾清贫难成人
不经打击老天真
自古英雄出炼狱
从来富贵入凡尘
展开
-
SDUT3364数据结构实验之图论八:欧拉回路
#includeusing namespace std;int uf[1050];int de[1005];int find0(int x){ int r=x; while(uf[r]!=r) r=uf[r]; int i=x,j; while(i!=r) { j=uf[i]; uf[i]=r;原创 2016-08-01 08:47:14 · 295 阅读 · 0 评论 -
SDUT1139数据结构上机测试2-2:单链表操作B
逆序建立链表,p从head->next开始遍历,q是前驱指针,r是后驱指针,比较r和p,相同删r。#includeusing namespace std;struct node{ int data; struct node *next;};int n;struct node *head,*p,*q,*r;void reverse_order_list(int n)原创 2016-06-08 23:19:10 · 345 阅读 · 0 评论 -
SDUT2116数据结构实验之链表一:顺序建立链表
#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*p;int n;void built(){ head=(struct node *)malloc(sizeof(struct node)); tail=head; while(n-原创 2016-07-22 08:49:36 · 284 阅读 · 0 评论 -
SDUT2117数据结构实验之链表二:逆序建立链表
#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*p;int n;void built(){ head=(struct node *)malloc(sizeof(struct node)); head->next=NULL; wh原创 2016-07-22 08:52:54 · 272 阅读 · 0 评论 -
SDUT2140图结构练习——判断给定图是否存在合法拓扑序列
#includeusing namespace std;int main(){ int v,e; while(~scanf("%d%d",&v,&e)) { bool map0[15][15]; int inde[15]; memset(map0,false,sizeof(map0)); memset(i原创 2016-08-02 15:59:33 · 240 阅读 · 0 评论 -
POJ2996Help Me with the Game
简单的模拟题,1a#include#include#include#include#include#include#includeusing namespace std;char Map[40][40];int t;void readMap(){ for(int i=0;i<17;i++) scanf("%s",Map[i]);}char tracol(int原创 2016-08-17 15:43:13 · 443 阅读 · 0 评论 -
SDUT3403数据结构实验之排序六:希尔排序
#includeusing namespace std;int a[10100],n;void shell(int dk){ int i,j; for(i=dk+1;i<=n;i++) { if(a[i]<a[i-dk]) { a[0]=a[i]; for(j=i-dk;j>0&&a[0原创 2016-08-05 18:39:19 · 309 阅读 · 0 评论 -
SDUT2088refresh的停车场
#includeusing namespace std;int f(char z[5]){ if(strcmp(z,"Add")==0) return 0; else if(strcmp(z,"Del")==0) return 1; else if(strcmp(z,"Out")==0) return 2;}void原创 2016-08-05 20:03:37 · 405 阅读 · 0 评论 -
SDUT数据结构实验之串三:KMP应用
#include#includeint n,m;int a[10000010];int b[10000010];void get_nextval(int pattern[],int next[]){ int j=0,k=-1; next[0]=-1; while(j<m) { if(k==-1||pattern[j]==pattern[k原创 2016-08-05 21:41:54 · 1733 阅读 · 0 评论 -
POJRobot Motion
1a,开心,模拟题#include#include#include#include#include#include#includeusing namespace std;int n,m,k;int Map[15][15];int road[15][15];int swh[4][2]={-1,0,0,1,1,0,0,-1};void Intmap(){ char ch原创 2016-08-16 21:35:36 · 448 阅读 · 0 评论 -
SDUT2506完美网络
#includeusing namespace std;int main(){ int n; scanf("%d",&n); while(n--) { int v,e,de[10050]; memset(de,0,sizeof(de)); priority_queue,greater > Q; s原创 2016-08-01 19:59:24 · 216 阅读 · 0 评论 -
SDUT3402数据结构实验之排序五:归并求逆序数
#includeusing namespace std;int a[100010],t[100010];long long cnt;void merger0(int s1,int e1,int s2,int e2){ int p=0; int p1=s1; int p2=s2; while(p1<=e1&&p2<=e2) { if(原创 2016-08-05 09:43:58 · 832 阅读 · 0 评论 -
SDUT3362数据结构实验之图论六:村村通公路
#include#include#include#includeusing namespace std;struct node{ int u,v,w; bool operator < (const node &x)const { return w<x.w; }} q[1000002];int e=0;int fa[100002];原创 2016-08-01 09:44:28 · 1324 阅读 · 0 评论 -
SDUT3400数据结构实验之排序三:bucket sort
感觉此题略水#includeusing namespace std;void bucketsort(int n){ int bucket[110]; memset(bucket,0,sizeof(bucket)); for(int i=0; i<n; i++) { int t; scanf("%d",&t);原创 2016-08-04 14:29:52 · 324 阅读 · 0 评论 -
SDUT3401数据结构实验之排序四:寻找大富翁
#includeusing namespace std;void heapadjust(int a[],int i,int n){ int lc=i*2; int rc=i*2+1; int t=i; if(i<=n/2) { if(lca[t]) t=lc; if(rca[t])原创 2016-08-04 16:55:08 · 277 阅读 · 0 评论 -
SDUT3363数据结构实验之图论七:驴友计划
#include#define MAX 2147483647using namespace std;struct ndoe{ int length,cost;} a[550][550];int v,e,v_start,v_end;void creat(){ for(int i=0; i<v; i++) for(int j=0; j<v; j++)原创 2016-08-01 14:44:36 · 440 阅读 · 0 评论 -
SDUT1130数据结构上机测试1:顺序表的应用(上一个代码太蠢)
#includeusing namespace std;int a[1050],hash[1050];int main(){ int n,k=0; scanf("%d",&n); for(int i=0; i<n; i++) scanf("%d",&a[i]); memset(hash,0,sizeof(hash)); for(int原创 2016-07-21 17:23:50 · 320 阅读 · 0 评论 -
SDUT1138数据结构上机测试2-1:单链表操作A
此题坑点在对末尾节点的操作,避免指针越界#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*q,*p;int n,key;void built(){ head=(struct node *)malloc(sizeof(struct node))原创 2016-07-21 18:35:39 · 243 阅读 · 0 评论 -
POJ2632Crashing Robots
1a,开心模拟题,恶心的很。。。。#include#include#include#include#include#include#includeusing namespace std;int T,A,B,N,M;bool flag;struct Map{ int id,dir;}a[120][120],t;int swhdir[4][2]={-1,0,0,1,原创 2016-08-16 17:01:53 · 229 阅读 · 0 评论 -
SDUT2413n a^o7 !
#includeusing namespace std;char a[20]="n5!wpuea^o7! ";char b[20]="usimdnaevoli ";int main(){ char t[150]; for(int i=0; i<13; i++) t[a[i]]=b[i]; int T; scanf("%d\n",&T);原创 2016-08-01 15:53:20 · 239 阅读 · 0 评论 -
SDUT数据结构实验之二叉树一:树的同构
#includeusing namespace std;struct tree{ char c; struct tree *lc,*rc;};struct node{ char s; int l,r;} a[15];struct tree * creat(int k){ struct tree *t; t=(struct tree原创 2016-08-06 10:17:16 · 1648 阅读 · 1 评论 -
SDUT3373数据结构实验之查找一:二叉排序树
#includeusing namespace std;struct tree{ int data; struct tree *lc,*rc;};void creat(struct tree *&node,int a){ if(node==NULL) { node=(struct tree *)malloc(sizeof(struct t原创 2016-08-02 21:56:43 · 326 阅读 · 0 评论 -
POJ2109Power of Cryptography
不知道算不算一道水题,题目本身的意思应该是用数组来模拟运算,但是double的精度以及位数恰好没有超过题目数据的范围,而且开方运算中后几位和前几位相比可以忽略掉影响,所以直接可以用pow函数。#include#include#include#include#includeusing namespace std;int main(){ double a,b; whi原创 2016-08-09 11:01:59 · 284 阅读 · 0 评论 -
PTA5-1 顺序存储的二叉树的最近的公共祖先问题 (25分)
其实就是用数组模拟然后不断除二,但是要注意两个节点差很远的情况,要先单独把大下标节点缩小#include#include#include#includeusing namespace std;int main(){ int n; scanf("%d",&n); int a[1050]; for(int i=1;i<=n;i++) sc原创 2016-08-09 20:46:19 · 778 阅读 · 0 评论 -
POJ2586Y2K Accounting Bug
这道题首先跪在了英语上。。。简单的贪心题,但是思路比较特别,巨巨舍友给我讲的,每月要么盈利要么亏损,且盈利和亏损是定值。每五月统计一次,每次统计要求亏损(好奇葩)几种情况如下ssssd ssssdssssdsssssdd sssddsssddssssddd ssdddssdddsssdddd sddddsddddsd如果不属于这四种情况,也要另计算值为-1#incl原创 2016-08-09 22:51:10 · 518 阅读 · 2 评论 -
SDUT3374数据结构实验之查找二:平衡二叉树
数据额结构查找表的难题详细参考课本,总之就是四种旋转 LL RR LR RL 后两种建立在前两种旋转的基础上。取孩子节点,把孩子节点的孩子节点连到夫节点的孩子节点,再把父节点连到孩子节点上。甩代码#include#include#include#include#includeusing namespace std;struct bt{ int data,b;原创 2016-08-11 11:30:50 · 590 阅读 · 0 评论 -
SDUT1047Color Me Less
#include#include#include#include#include#define MAX 0x3f3f3fusing namespace std;struct node{ double r,g,b;} a[20];double fd(struct node t,double x,double y,double z){ return sqrt((t原创 2016-08-11 15:10:02 · 240 阅读 · 0 评论 -
POJ2524Ubiquitous Religions
裸并查集没啥说的#include#include#include#include#includeusing namespace std;int uf[50050];int find(int x){ int r=x; while(uf[r]!=r) r=uf[r]; return r;}void merge(int x,int y){ int fx原创 2016-08-13 14:15:02 · 231 阅读 · 0 评论 -
POJ2506Tiling
数组模拟大数这种东西。。上模板就好。。。感谢模板作者。。。#include#include#include#include#include#include#include #include using namespace std;const int Base=1000000000;const int Capacity=100;typedef long long huge;原创 2016-08-13 15:47:49 · 302 阅读 · 0 评论 -
分享一份很好的vim配置文件
vim强大的编辑器,官网下载不多说。这份文件可以使用gcc/g++编译,并且解决中文乱码。记得修改Path。感谢原作者的努力。set nocompatiblesource $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbehave mswinset diffexpr=MyDiff()function MyDif转载 2016-08-15 08:17:36 · 672 阅读 · 1 评论 -
SDUT1081Above Average
水题,学会了怎么打印%#include#include#include#includeusing namespace std;int main(){ int C; scanf("%d",&C); while(C--) { int N,k=0; double a[1050],s=0; scanf("%d"原创 2016-08-09 10:30:02 · 202 阅读 · 0 评论 -
SDUT1075Doubles
日常水题,数组开大些,不要吝啬内存。。。会re的。。。#include#include#include#includeusing namespace std;int main(){ int t,a[10000],top=0; bool v[10000]; memset(v,false,sizeof(v)); memset(a,0,sizeof(a))原创 2016-08-09 09:25:18 · 258 阅读 · 0 评论 -
SDUT1009Elevator
日常水题~#include#include#includeusing namespace std;int main(){ int N; while(~scanf("%d",&N)&&N) { int a[105],s=5*N,t; a[0]=0; for(int i=1; i<=N; i++)原创 2016-08-09 08:50:06 · 243 阅读 · 0 评论 -
SDUT3375数据结构实验之查找三:树的种类统计
#includeusing namespace std;int n;struct tree{ char data[22]; int cnt; struct tree *lc,*rc;};void creat(struct tree*&t,char s[]){ if(t==NULL) { t=(struct tree *)mall原创 2016-08-03 09:09:47 · 634 阅读 · 0 评论 -
POJ2993Emag eht htiw Em Pleh
终于撸完了最后一道模拟题,恶心死我了。。。#include#include#include#include#include#include#includeusing namespace std;char Map[40][40];void IntMap(){ for(int i=0;i<17;i++) { for(int j=0;j<33;j++) { i原创 2016-08-17 20:47:40 · 306 阅读 · 0 评论 -
HDU5804&BestCoder Round #86 1001 Price List
注意数据范围,用longlong,开数组会超时,直接输出就好。#includeusing namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int n,m; scanf("%d%d",&n,&m); long long int s=0;原创 2016-08-07 09:46:08 · 313 阅读 · 0 评论 -
POJ1753Flip Game
第一道poj题,简单枚举+dfs,poj没有题解根本刚不过,代码和题解高度相似。这道题难点在于对递归的理解。step记录步数,棋盘模型决定了step上限是16,暴力枚举出每次到达相应步数的所有情况,进行判断,flag为真时找到步数,输出,结束。//测试无法找到答案时递归次数为2^16次。1753 Accepted164K 235MSC++ 1202B#includeusing原创 2016-08-07 15:51:31 · 277 阅读 · 0 评论 -
POJ2965The Pilots Brothers' refrigerator
和上一道简单枚举dfs相似,区别是需要用结构体数组模拟栈,记录位置。出栈时要用flag判断,当找到答案时就不再出栈。wa好几次,读题不精,这道题需要所有开关都是打开状态,才可以开门,以及自己是用布尔变量保存图,然而在判断时忘记了,又wa好几发。通过这两道题可以加深对dfs搜索和地柜函数的认识。Accepted164K704MSC++1324B#i原创 2016-08-07 16:38:50 · 236 阅读 · 0 评论 -
POJ3278Catch That Cow
让我re了好几发的题,后来跟着标称一行一行的对比,发现我的判断顺序有问题。要先判断是否越界,再判断标记变量,否则会指针越界。#include#include#include#include#include#include#includeusing namespace std;const int N = 200100;int n,k;struct state{ i原创 2016-08-18 14:14:42 · 314 阅读 · 0 评论 -
PTA5-1 任务调度的合理性
假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比如英语和C程序设计,它们没有必须先修哪门的约束;有些课程则不可以同时开设,因为它们有先后的依赖原创 2016-08-20 08:46:29 · 707 阅读 · 0 评论