2012年8月3日

HDU 2034 人见人爱A-B

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int cmp(const void *a,const void *b) 4 { 5 return *(int *)a-*(int *)b;//升序 6 } 7 int main() 8 { 9 int a[110],b[110];10 int n,m,i,flag;11 while(~scanf("%d%d",&n,&m)&&(n||m))12 {13 for(i=0;i<n;i++)14 scanf("%d&quo 阅读全文

posted @ 2012-08-03 18:28 mycapple 阅读(2535) 评论(0) 推荐(0)

HDU 2009 求数列的和

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int i,n; 6 double x,s; 7 while(scanf("%lf%d",&x,&n)!=EOF) 8 { 9 for(s=0.0;n--;x=sqrt(x))10 s+=x;11 printf("%.2lf\n",s);12 }13 return 0;14 } 阅读全文

posted @ 2012-08-03 17:56 mycapple 阅读(240) 评论(0) 推荐(0)

HDU 2011 多项式求和

摘要: 1 #include<stdio.h> 2 int n; 3 double rev(int c) 4 { 5 return c<=n?(((c&1)?1.0:-1.0)/c+rev(c+1)):0 ; 6 } 7 int main() 8 { 9 int t;10 scanf("%d",&t);11 while(t--&&scanf("%d",&n))12 printf("%.2lf\n",rev(1));13 return 0;14 } 阅读全文

posted @ 2012-08-03 17:56 mycapple 阅读(472) 评论(0) 推荐(0)

HDU 2008 数值统计

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int a,b,c,i,n; 5 double x; 6 while(scanf("%d",&n),n) 7 { 8 a=b=c=0; 9 for(i=0;i<n;i++)10 {11 scanf("%lf",&x);12 if(x<0) a++;13 else if(x>0) c++;14 else b++;15 }... 阅读全文

posted @ 2012-08-03 17:54 mycapple 阅读(339) 评论(0) 推荐(0)

HDU 2007 平方和与立方和

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 unsigned m,n,i,x,y; 5 while(scanf("%u%u",&m,&n)!=EOF) 6 { 7 if(m>n) 8 { 9 i=m;10 m=n;11 n=i;12 }13 x=y=0;14 for(i=m;i<=n;i++) 15 (i&1)?(y+=i*i*i):(x+=i*i);16 ... 阅读全文

posted @ 2012-08-03 17:52 mycapple 阅读(1601) 评论(0) 推荐(0)

HDU 2005 第几天?

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int year,month,day,i; 5 while(scanf("%d/%d/%d",&year,&month,&day)!=EOF) 6 { 7 i=0; 8 switch(month-1) 9 {10 case 11: i+=30;11 case 10: i+=31;12 case 9: i+=30;13 case 8... 阅读全文

posted @ 2012-08-03 17:50 mycapple 阅读(1464) 评论(0) 推荐(0)

HDU 2004 成绩转换

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int r; 5 while(scanf("%d",&r)!=EOF) 6 { 7 if(r<0) 8 puts("Score is error!"); 9 else if(r<60)10 puts("E");11 else if(r<70)12 puts("D");13 else if(r<80)14 puts("C");15 else i... 阅读全文

posted @ 2012-08-03 17:49 mycapple 阅读(413) 评论(0) 推荐(0)

HDU 2003 求绝对值

摘要: 1 #include <stdio.h> 2 #include<math.h> 3 int main() 4 { 5 double r; 6 while(scanf("%lf",&r)!=EOF) 7 printf("%.2lf\n",fabs(r)); 8 return 0; 9 }10 阅读全文

posted @ 2012-08-03 17:48 mycapple 阅读(425) 评论(0) 推荐(0)

HDU 2002 计算球体积

摘要: 1 #include<stdio.h>2 #define PI 3.14159273 int main()4 {5 double r;6 while(scanf("%lf",&r)!=EOF)7 printf("%.3lf\n",r/3*4*r*r*PI);8 return 0;9 } 阅读全文

posted @ 2012-08-03 17:47 mycapple 阅读(1022) 评论(0) 推荐(0)

HDU 2001 计算两点间的距离

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 double x1,y1,x2,y2,r; 6 while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF) 7 { 8 r=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); 9 printf("%.2lf\n",r);10 }11 return 0;12 } 阅读全文

posted @ 2012-08-03 17:46 mycapple 阅读(1072) 评论(0) 推荐(0)

HDU 2033 人见人爱A+B

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int T; 6 int h,m,s,hh,mm,ss; 7 scanf("%d",&T); 8 while(T--) 9 {10 scanf("%d%d%d%d%d%d",&h,&m,&s,&hh,&mm,&ss);11 s+=ss;12 if(s>60)13 m++;s%=60;//减去一个数不如对它取余14 m+=mm;15 if(m... 阅读全文

posted @ 2012-08-03 17:45 mycapple 阅读(213) 评论(0) 推荐(0)

HDU 2032 杨辉三角

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int main() 5 { 6 int ret[50][50],i,j,n; 7 ret[1][1]=ret[2][1]=ret[2][2]=1; 8 for(i=3;i<=30;i++) 9 {10 for(j=2;j<=i-1;j++)11 {12 ret[i][j]=ret[i-1][j-1]+ret[i-1][j];13 }14 ret[... 阅读全文

posted @ 2012-08-03 17:25 mycapple 阅读(527) 评论(0) 推荐(0)

NYOJ 305 表达式求值

摘要: 法一: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 //这个表达式求值,要先算最小单元的数值,可以采用递归方式 5 char str[350];//使用全局数据保存字符串 6 int first;//字符当前位置 7 int min(int x,int y) 8 { 9 return x>y ? y:x;//返回比较小的数10 }11 int max(int x,int y)12 {13 return x>y ? x:y;//返回比较大的数14 }15 int f 阅读全文

posted @ 2012-08-03 16:38 mycapple 阅读(447) 评论(0) 推荐(0)

sscanf函数的用法

摘要: 函数原型: Int sscanf( const char * src, const char * format, ...);int scanf( const char * format, ...);这两个函数很相似,只是第一个函数以src作为输入,而第二个函数以标准输入STDIN读取输入;format 是格式控制字符串,它包含控制字符(如:%d,%i,%s等),空白字符(如:空格、制表符\t、回车换行符\n 或其连续组合)以及非空白字符;...是一组指针变量,是上述函数用来保存结果值的;返回值为被成功赋值的指针变量的个数,如果该函数发生错误,则返回EOF(-1)。 格式控制format: fo 阅读全文

posted @ 2012-08-03 15:12 mycapple 阅读(18307) 评论(0) 推荐(0)

POJ 1298 The Hardest Problem Ever

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int main() 5 { 6 char s1[110]; 7 char s2[15]; 8 int i,n; 9 while(1)10 {11 gets(s2);12 if(strcmp(s2,"ENDOFINPUT")==0)13 break;14 else if(strcmp(s2,"START")==0)15 {16 ... 阅读全文

posted @ 2012-08-03 14:56 mycapple 阅读(289) 评论(0) 推荐(0)

NYOJ 221 Tree

摘要: 1 #include <iostream> 2 #include<cstdio> 3 #include <string> 4 using namespace std; 5 struct Node{ 6 char data; 7 Node* lchild; 8 Node* rchild; 9 };10 Node* CreateTree(string pre,string in)11 {12 Node* root = NULL;13 if(pre.length()>0)14 {15 root = new Node;16 ... 阅读全文

posted @ 2012-08-03 11:03 mycapple 阅读(273) 评论(0) 推荐(0)

POJ 2255 Tree Recovery

摘要: 已知二叉树的前序遍历序列和中序遍历序列,求后序遍历序列。先递归构造二叉树,再递归后序遍历。思路:前序序列的第一个结点为要构造的二叉树的根节点,在中序序列中查找此节点,则其左为要构造的二叉树的左子树的中序序列,其右为要构造的二叉树的右子树的中序序列。而前序序列根节点后面分别跟着它的左子树和右子树的前序序列。有了根节点在中序序列中的位置,就知道了左子树和右子树的前序序列分别占据了前序序列中的那些位置,这样,就分别知道了两棵子树所代表的子序列。然后在构造了根结点后,就可以递归调用函数自身来分别构造根节点的左子树和右子树。以上为二叉树的构造即恢复。后序遍历二叉树也用递归。 1 #include < 阅读全文

posted @ 2012-08-03 11:01 mycapple 阅读(340) 评论(0) 推荐(0)

归并排序

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define FALSE 0 5 #define MAX_NUM 100 6 typedef int Status; 7 typedef int ElemType; 8 typedef struct SqList 9 {10 ElemType r[MAX_NUM];11 int length;12 }SqList;13 void Merge(ElemType SR[],ElemType TR[],int i,int m,int n)14 {15 int. 阅读全文

posted @ 2012-08-03 09:22 mycapple 阅读(240) 评论(0) 推荐(0)

堆排序

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define FALSE 0 5 #define MAX_NUM 100 6 typedef int Status; 7 typedef int ElemType; 8 typedef struct SqList 9 {10 ElemType r[MAX_NUM];11 int length;12 }SqList;13 typedef SqList HeapType;14 Status Exchange(ElemType &a,ElemType 阅读全文

posted @ 2012-08-03 09:21 mycapple 阅读(302) 评论(0) 推荐(0)

最小生成树(普里姆)

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define TRUE 1 5 #define FALSE 0 6 #define ERROR -1 7 #define OVERFLOW -2 8 #define INFINITY 65535 9 #define MAX_VERTEX_NUM 2010 typedef int Status;11 typedef char TreeType;12 //定义邻接矩阵数据结构 13 typedef struct14 {15 TreeType vexs[MAX 阅读全文

posted @ 2012-08-03 09:20 mycapple 阅读(292) 评论(0) 推荐(0)

邻接矩阵

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define TRUE 1 5 #define FALSE 0 6 #define ERROR -1 7 #define OVERFLOW -2 8 #define MAX_VERTEX_NUM 20 9 bool visited[MAX_VERTEX_NUM]; 10 typedef int QElemint; 11 typedef int Status; 12 //定义队列数据结构 13 typedef struct QNode 14 { 15 .. 阅读全文

posted @ 2012-08-03 09:19 mycapple 阅读(386) 评论(0) 推荐(0)

最短路径(Dijkstra)

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define TRUE 1 5 #define FALSE 0 6 #define ERROR -1 7 #define OVERFLOW -2 8 #define INFINITY 65535 9 #define MAX_VERTEX_NUM 10 10 typedef int Status; 11 typedef char TreeType; 12 int P[MAX_VERTEX_NUM];//用于存放最短路径,P[i]存放i的前驱结点序号 13 阅读全文

posted @ 2012-08-03 09:19 mycapple 阅读(285) 评论(0) 推荐(0)

链式堆栈

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define Stackincrement 10 5 #define ok 1 6 #define error -1 7 #define overflow 2 8 #define TRUE 1 9 #define FALSE 010 typedef int status;11 typedef struct12 {13 int *base;14 int *top;15 int stacksize;16 }SqStack;17 statu 阅读全文

posted @ 2012-08-03 09:18 mycapple 阅读(342) 评论(0) 推荐(0)

顺序堆栈

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define StackIncrement 10 5 #define OK 1 6 #define TRUE 1 7 #define FALSE 0 8 #define ERROR -1 9 #define OVERFLOW -210 typedef int Status;11 typedef struct12 {13 int *base;14 int *top;15 int stacksize;16 }SqStack;17 Sta. 阅读全文

posted @ 2012-08-03 09:17 mycapple 阅读(330) 评论(0) 推荐(0)

改进的KMP模式匹配算法

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 int next[12],la,lb; 4 void GetNext(char T[]) 5 { 6 int j=1,k=0; 7 next[1]=0; 8 while(j<=la) 9 { 10 if(k==0||T[j]==T[k])11 { 12 ++j;13 ++k;14 if(T[k]==T[j])15 next[j]=next[k... 阅读全文

posted @ 2012-08-03 09:16 mycapple 阅读(422) 评论(0) 推荐(0)

摘要: 1 #include<> 2 typedef struct 3 { 4 char *ch; 5 int length; 6 }HString; 7 Status StrAssign(Hstring &T,char *chars) 8 { 9 if(T.ch) free(T.ch);10 for(i=0,c=chars;c;i++,c++)11 if(!i)12 {13 T.ch=NULL;14 T.length=0;15 }16 else{17 if(!(T.ch=(char *)... 阅读全文

posted @ 2012-08-03 09:15 mycapple 阅读(258) 评论(0) 推荐(0)

已知二叉树的前序与中序遍历创建二叉树

摘要: 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 struct Node 7 { 8 char data; 9 Node *lchild;10 Node *rchild;11 };12 Node *CreatTree(string pre,string in)13 {14 Node *root=NULL;15 if(pre.length()>0)16 {17 root... 阅读全文

posted @ 2012-08-03 09:14 mycapple 阅读(392) 评论(0) 推荐(0)

内部排序H

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 #include<iostream.h> 4 #include<stdlib.h> 5 #define OK 1 6 #define FALSE 0 7 #define MAX_NUM 100 8 typedef int Status; 9 typedef int ElemType; 10 typedef struct SqList 11 { 12 ElemType r[MAX_NUM]; 13 int length; 14 }SqList; 15 typedef 阅读全文

posted @ 2012-08-03 08:21 mycapple 阅读(354) 评论(0) 推荐(0)

邻接表

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<iostream.h> 4 #define OK 1 5 #define TRUE 1 6 #define FALSE 0 7 #define ERROR -1 8 #define OVERFLOW -2 9 #define MAX_VEX_NUM 20 10 using namespace std; 11 typedef int Status; 12 //定义邻接表存储类型 13 typedef char VexType; 14 typedef stru 阅读全文

posted @ 2012-08-03 08:20 mycapple 阅读(2886) 评论(0) 推荐(0)

二叉排序树M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define TRUE 1 5 #define FALSE 0 6 #define ERROR -1 7 #define OVERFLOW -2 8 typedef int Status; 9 typedef int KeyType; 10 typedef int TElemType; 11 typedef struct BiTNode{ 12 TElemType data; 13 BiTNode *lchild,*rchild; 14 }... 阅读全文

posted @ 2012-08-03 08:19 mycapple 阅读(375) 评论(0) 推荐(0)

二叉树递归遍历操作M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define ok 1 4 #define error 0 5 typedef int status; 6 typedef char TElemType; 7 typedef struct BiTNode 8 { 9 TElemType data; 10 struct BiTNode *lchild,*rchild; 11 }BiTNode,*BiTree; 12 13 void InitBiTree(BiTree &T) 14 { 15 T=NULL; 16 } ... 阅读全文

posted @ 2012-08-03 08:18 mycapple 阅读(358) 评论(0) 推荐(0)

二叉树非递归M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define StackIncrement 10 5 #define OK 1 6 #define TRUE 1 7 #define FALSE 0 8 #define ERROR 0 9 #define OVERFLOW -2 10 typedef int Status; 11 typedef char TElemType; 12 typedef struct BiTNode 13 { 14 TElemType data; 15.. 阅读全文

posted @ 2012-08-03 08:18 mycapple 阅读(330) 评论(0) 推荐(0)

稀疏矩阵的十字链表存储表示和实现

摘要: 1 #include <stdio.h> 2 #include <malloc.h> 3 typedef int ElemType;// 稀疏矩阵的十字链表存储表示 4 typedef struct OLNode 5 { 6 int i,j; // 该非零元的行和列下标 7 ElemType e; // 非零元素值 8 struct OLNode *right,*down; // 该非零元所在行表和列表的后继链域 9 }OLNode, *OLink; 10 typedef struct// 行和列链表头指针向量基址,由CreatS... 阅读全文

posted @ 2012-08-03 08:17 mycapple 阅读(10830) 评论(0) 推荐(1)

十字链表M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define TRUE 1 4 #define FALSE -1 5 #define ERROR 0 6 #define OK 1 7 #define OVERFLOW -2 8 #define LEN1 sizeof(OLink) 9 #define LEN2 sizeof(OLNode) 10 typedef int Status; 11 typedef int ElemType; 12 typedef struct OLNode{ 13 int i,j; 14 El... 阅读全文

posted @ 2012-08-03 08:16 mycapple 阅读(647) 评论(0) 推荐(0)

循环队列M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define TRUE 1 4 #define FALSE 0 5 #define ERROR 0 6 #define OK 1 7 #define OVERFLOW -2 8 #define MAXQSIZE 100 9 #define LEN sizeof(QElemType)10 typedef int Status;11 typedef int QElemType;12 typedef struct13 {14 QElemType *base;15 int front;16 阅读全文

posted @ 2012-08-03 08:14 mycapple 阅读(275) 评论(0) 推荐(0)

链式队列M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define ok 1 4 #define error 0 5 #define overflow -1 6 #define TRUE 1 7 #define FALSE 0 8 #define status int 9 typedef struct QNode 10 { int data; 11 struct QNode *next; 12 }QNode,*QueuePtr; 13 typedef struct 14 { QueuePtr front; 15 QueueP... 阅读全文

posted @ 2012-08-03 08:14 mycapple 阅读(191) 评论(0) 推荐(0)

中缀表达式-后缀表达式M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define StackIncrement 10 5 #define Ok 1 6 #define Error 0 7 #define True 1 8 #define False 0 9 #define Overflow -2 10 typedef int status; 11 //字符栈的操作 12 typedef struct 13 { 14 char *base; 15 char *top; 16 int stacks... 阅读全文

posted @ 2012-08-03 08:13 mycapple 阅读(424) 评论(0) 推荐(0)

括号匹配M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #define Stack_Size 100 5 #define Stackincrement 10 6 #define ok 1 7 #define error 0 8 #define overflow 2 9 #define true 1 10 #define false 0 11 typedef int status; 12 typedef struct 13 { 14 char *base; 15 char *top; 16 阅读全文

posted @ 2012-08-03 08:12 mycapple 阅读(244) 评论(0) 推荐(0)

进制数转换M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define Stackincrement 10 5 #define ok 0 6 #define error -1 7 #define overflow 2 8 #define TRUE 1 9 #define FALSE 0 10 typedef int status; 11 typedef struct 12 { 13 int *base; 14 int *top; 15 int stacksize; 16 }SqSta... 阅读全文

posted @ 2012-08-03 08:10 mycapple 阅读(322) 评论(0) 推荐(0)

后缀表达式求解MH

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define StackIncrement 10 5 #define Ok 1 6 #define Error 0 7 #define Overflow -2 8 #define True 1 9 #define False -1 10 typedef int status; 11 //数字栈的操作 12 typedef struct 13 { 14 float *base; 15 float *top; 16 int sta... 阅读全文

posted @ 2012-08-03 08:09 mycapple 阅读(298) 评论(0) 推荐(0)

表达式求值M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define Stack_Size 100 4 #define StackIncrement 10 5 #define Ok 1 6 #define Error 0 7 #define Overflow -2 8 #define True 1 9 #define False 0 10 typedef int status; 11 char s[100]; 12 //字符栈的操作 13 typedef struct 14 { 15 char *base; 16 char *top... 阅读全文

posted @ 2012-08-03 08:08 mycapple 阅读(220) 评论(0) 推荐(0)

链表的插入与删除M

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define OK 1 4 #define error -1 5 typedef struct LNode 6 { 7 int data; 8 struct LNode *next; 9 }LNode,*LinkList;10 LinkList CreateList(int n)11 {12 LinkList L,p,s;13 int i; 14 L=(LinkList)malloc(sizeof(LNode));15 L->next=NULL;L... 阅读全文

posted @ 2012-08-03 08:07 mycapple 阅读(385) 评论(0) 推荐(0)

顺序表的插入与删除M

摘要: 1 #define LIST_SIZE 80 2 #define LISTINCREMENT 10 3 #define ok 1 4 #define overflow -1 5 #define error -2 6 #include<stdio.h> 7 #include<stdlib.h> 8 typedef struct 9 {10 int *elem;11 int length;12 int listsize;13 }sqlist;14 int initlist(sqlist &L)15 {16 L.elem=(int *)malloc(LIST_SIZE 阅读全文

posted @ 2012-08-03 08:05 mycapple 阅读(626) 评论(0) 推荐(0)

顺序表的就地逆置M

摘要: 1 #define LIST_SIZE 80 2 #define LISTINCREMENT 10 3 #define ok 1 4 #define overflow -1 5 #define error -2 6 #include<stdio.h> 7 #include<stdlib.h> 8 typedef struct 9 {10 int *elem;11 int length;12 int listsize;13 }sqlist;14 int initlist(sqlist &L)15 {16 L.elem=(int *)malloc(LIST_SIZE 阅读全文

posted @ 2012-08-03 08:05 mycapple 阅读(1545) 评论(0) 推荐(0)

HDU 3785- 寻找大富翁

摘要: 1 /*algorithm 是算法的意思 2 #include <algorithm> 包括各种数据结构的具体元素检索、替换、逆序等等通用的算法 3 */ 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 bool cmp(int a,int b) 8 { 9 if(a>b)10 return true; //降序 11 else12 return false;13 }14 int main()15 {16 int m,n,i;17 int a[100... 阅读全文

posted @ 2012-08-03 08:03 mycapple 阅读(340) 评论(0) 推荐(0)

ZJU 1217 大数相乘

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char a[220],b[220]; 6 int m[220],n[220],c[440]; 7 int i,j,k,t,la,lb,signa,signb; 8 char *pa,*pb; 9 while(1)10 {11 signa=signb=0;12 scanf("%s%s",a,b);13 pa=a;pb=b;14 if(a[0]=='-') {sig... 阅读全文

posted @ 2012-08-03 08:02 mycapple 阅读(249) 评论(0) 推荐(0)

NYOJ 216-A problem is easy

摘要: 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int i,m,n,k,t; 6 scanf("%d",&n); 7 while(n--) 8 { 9 scanf("%d",&m);10 t=sqrt(m+1);11 for(i=2,k=0;i<=t;i++)12 if((m+1)%i==0)13 k++;14 printf("%d\n",k);15 }16 return 0;17 ... 阅读全文

posted @ 2012-08-03 08:01 mycapple 阅读(224) 评论(0) 推荐(0)

POJ 1363 Rails

摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int sq[1000],a[1000];//sq为栈,a为B的出栈元素 5 int i,k,n,head; 6 while(scanf("%d",&n),n)//n为0则结束 7 { 8 while(scanf("%d",&a[0]),a[0])//a[0]=0的话表示本次数据结束 9 { 10 head=0;11 for(i=1;i<n;i++)12 scanf("%d"... 阅读全文

posted @ 2012-08-03 07:58 mycapple 阅读(273) 评论(0) 推荐(0)

NYOJ 35 表达式求值

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define N 1010 4 char s[N]; 5 //字符栈的操作 6 typedef struct 7 { 8 char *base; 9 char *top; 10 }SqStack1; 11 int InitStack1(SqStack1 &S) 12 { 13 S.base=(char *)malloc(N*sizeof(char)); 14 if(!S.base) exit(1); 15 S.top=S.ba... 阅读全文

posted @ 2012-08-03 07:55 mycapple 阅读(312) 评论(0) 推荐(0)

导航