04 2013 档案
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct listNode{ 5 char data; 6 struct listNode *nextPtr; 7 }; 8 typedef struct listNode LISTNODE; 9 typedef LISTNODE *LISTNODEPTR; 10 11 void insertList(LISTNODEPTR *,char); 12 char deleteList(LISTNODEPTR *,char); 13 int isEmpty...
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>/* Copyright Derek Kisman (ACM ICPC ECNA 1999) */char map[26] = {'2', '2', '2', '3', '3', '3', '4', '4', '4', '5', '5', '5', '
阅读全文
摘要:时间复杂度为N方 1 #include <iostream> 2 3 using namespace std; 4 //最长子序列 5 6 int MaxSequence(int a[],int N) 7 { 8 int thisSum,maxSum=0,i,j; 9 for(i=0;i<N;i++)10 {11 thisSum=0;12 for(j=i;j<N;j++)13 {14 thisSum+=a[j];15 if(thisSum>maxSum)16 ...
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <windows.h> 4 #include <time.h> 5 #include <string.h> 6 #define M 4 7 #define B 2 8 #define S 2 9 typedef char keytype; 10 11 12 /*=================机票结构体=============*/ 13 typedef struct Ticket 14 { 15 char m_number[
阅读全文
摘要:#include <iostream>using namespace std; bool isPrimeNumber(int a){ int i; for(i=2;i*i<=a;i++) { if(a%i==0) { //flag=0; return false; } } return true;};bool judge_prime(int digit){ int i,flag; if(digit%2==0) return false; ...
阅读全文
摘要:初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法: (1)图的深度优先遍历和广度优先遍历. (2)最短路径算法(dijkstra,bellman-ford,floyd,heap+dijkstra) (poj1860,poj3259,poj1062,poj2253,poj1125,poj2240) (3)最小生成树算法(prim,krus
阅读全文
摘要://Memory Time//232K 0MS#include<iostream>#include<algorithm>#include<cstring>using namespace std;int main(void){ int room[401]; int test,move_time,i,j,temp; int from[200],to[200]; cin>>test; for(j=0;j<test;j++) { memset(room,0,sizeof(room)); //注意每次测试都要初始化,而不是在输入测试次数前初始化 ..
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>int main(){ //printf("Hello world!\n"); int n; scanf("%d",&n); int pant[100][100]={0}; int i,j; while(n!=0) { char str[5]; int x,y,l; scanf("%s%d%d%d",&str,&x,&y,&l); if(str[0]=='B') { //scanf(
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>int main(){ //printf("Hello world!\n"); int n; scanf("%d",&n); while(n!=0) { int x,y,z; scanf("%d%d%d",&x,&y,&z); if(x>(y-z)) printf("do not advertise\n"); else if(x==(y-z)) printf("does
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>int main(){ //printf("Hello world!\n"); int n; scanf("%d",&n); while(n!=0) { int x,y; scanf("%d%d",&x,&y); if(x<y) printf("NO BRAINS\n"); else printf("MMM BRAINS\n"); n--; } return 0;}
阅读全文
摘要://Memory Time//240K 0MS#include<iostream>#include<math.h>#include<string>#include<iomanip>using namespace std;int main(void){ char alpha; double t,d,h; int i; for(;;)//等于while(true) { t=d=h=200; //三个参数的范围默认都是在-100 ~ 100 for(i=0;i<2;i++) { cin>...
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>#include <time.h>struct card{char *suit;char *face;};typedef struct card Card;void fillDeck(Card *,char *[],char *[]);void shuffle(Card *);void deal(Card *);int main(){ Card deck[52]; char *face[]={"1","2","3","
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>#define SIZE 10//quickSortint part(int *a,int p,int r){ int x=a[r]; int i=p-1; int j,temp; int temp2; for(j=p;j<=r-1;j++) { if(a[j]<=x) { i++; temp=a[i]; a[i]=a[j]; a[j]=temp; } ...
阅读全文
浙公网安备 33010602011771号