恒邪

2014年4月2日 #

[ACM] hdu 1286 找新朋友(欧拉函数)

摘要: 找新朋友Time Limit: 2000/1000 MS(Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s):6928Accepted Submission(s): 3593Problem Description新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数,否则都是新朋友,现在会长想知道究竟有几个新朋友?请你编程序帮会长计算出来。Input第一行是测试数据的组数CN(Casenu 阅读全文

posted @ 2014-04-02 20:39 恒邪 阅读(160) 评论(0) 推荐(0) 编辑

环形队中实现队列的基本运算

摘要: /*队空条件:front=rear队满条件:(rear+1)%MaxSize=front进队e操作:rear=(rear+1)%MaxSize; 将e放在rear处出队操作:front=(front+1)%MaxSize;取出front处元素e; */#include #include using namespace std;const int maxn=4;typedef struct{ int data[maxn]; int front,rear;}queue;//初始化队列void init(queue *&q){ q=(queue*)malloc(sizeof(que... 阅读全文

posted @ 2014-04-02 19:17 恒邪 阅读(341) 评论(0) 推荐(0) 编辑

队列的顺序存储结构及其基本运算的实现

摘要: 代码:#include #include using namespace std;const int maxn=500;typedef struct{ int data[maxn]; int front,rear;}queue;//初始化队列void init(queue *&q){ q=(queue*)malloc(sizeof(queue)); q->rear=q->front=-1;}//销毁队列void destroy(queue *&q){ free(q);}//判断队列是否为空bool empty(queue *&q){ return q-> 阅读全文

posted @ 2014-04-02 18:56 恒邪 阅读(293) 评论(0) 推荐(0) 编辑

栈的链式存储结构及其基本运算实现

摘要: #include #include using namespace std;typedef struct linknode{ int data; struct linknode *next;}Listack;//初始化栈void init(Listack *&s){ s=(Listack*)malloc(sizeof(Listack)); s->next=NULL;}//摧毁栈void destroy(Listack *&s){ Listack *p=s,*q=s->next; while(q!=NULL) { free(p); ... 阅读全文

posted @ 2014-04-02 18:21 恒邪 阅读(206) 评论(0) 推荐(0) 编辑

栈的顺序存储结构及其基本运算实现

摘要: #include #include using namespace std;const int maxn=500;typedef struct { int data[maxn]; int top;}Stack;//初始化stackvoid init(Stack *&s){ s=(Stack *)malloc(sizeof(Stack)); s->top=-1;}//销毁stackvoid destroy(Stack *&s){ free(s);}//判断栈是否为空bool empty(Stack *s){ return (s->top==-1);}//进stackv 阅读全文

posted @ 2014-04-02 18:20 恒邪 阅读(186) 评论(0) 推荐(0) 编辑

导航