编程语言
_creek
这个作者很懒,什么都没留下…
展开
-
2014-12-23
[输出100到200之间的素数]#includeint main(){ int i,j,count=0; for(i=100;i<=200;i++) { for(j=2;j<i/2;j++) { if(i%j==0)break; } printf("%d\t",i); count++; if(count%5==0) { prin原创 2014-12-23 17:36:06 · 265 阅读 · 0 评论 -
栈基本操作及应用举例
#pragma once#include#includeusing namespace std;typedef int ElemType;#define STACK_INIT_SIZE 20typedef struct Stack{ ElemType *base; int top; int capacity;}Stack;bool IsF原创 2015-05-12 11:41:35 · 305 阅读 · 0 评论 -
栈 函数的实现
#ifndef _SEQSTACK_H#define _SEQSTACK_H#include#includeusing namespace std;typedef int ElemType;#define STACK_INIT_SIZE 5#define STACKINCREMENT 2typedef struct Stack{ ElemType *base;原创 2015-05-10 19:43:28 · 246 阅读 · 0 评论 -
双向循环链表 函数的实现
#include"list.h"void InitList(List *list){ Node *s=(Node *)malloc(sizeof(Node)); assert(s!=NULL); list->first=list->last=s; list->first->prev=list->last; list->last->next=list->first; lis原创 2015-05-10 19:38:56 · 355 阅读 · 0 评论 -
单循环链表中各种函数的实现
List.h#ifndef _LIST_H#define _LIST_H#include#includeusing namespace std;#define ElemType inttypedef struct Node{ ElemType data; struct Node *next;}Node, *PNode;typedef struct List{原创 2015-05-10 19:35:28 · 327 阅读 · 0 评论 -
求n的k次方
#includeint my_pow(int n,int k){ int ret=0; if(k==1) { return n; } ret=n*my_pow(n,k-1); return ret;}int main(){ printf("%d\n",my_pow(4,4)); return 0;}原创 2015-03-14 17:11:04 · 725 阅读 · 0 评论 -
整形数的数字求和
#includeint DigitSum(int n){ int m; m=n%10; if(n!=0) n/=10; else return m; return m+DigitSum(n);}int main(){ printf("%d\n",DigitSum(2015)); return 0;}原创 2015-03-14 17:10:53 · 282 阅读 · 0 评论 -
通讯录的实现
#ifndef _CONTACTS_H_#define _CONTACTS_H_#define NAME_LENGTH 20#define SEX_LENGTH 10#define TELE_LENGTH 11#define ADDR_LENGTH 30#define MAX 1000struct PeopleInfo{ char name[NAME_LENGTH]; i原创 2015-03-20 16:42:24 · 221 阅读 · 0 评论 -
strrchr的实现
strrchr,用来查找一个字符串中某个字符出现的最后位置这个函数返回的是某个字符最后一次出现的地址#include#includechar *my_strrchr(char const*string,int ch){ char *str; char *temp; str=strchr(string,ch); while(str!=NULL)//当str为空时原创 2015-03-20 20:00:46 · 837 阅读 · 0 评论 -
字符反转输出
#includevoid fun(char *string){ if(*string!='\0') { fun(string+1);//递归调用 //fun(string++) 程序崩溃,因为每次指向的都是a的地址,无限循环下去 //fun(string+=1) 只输出dcb printf("%c",*string); }}int main(){ char st原创 2015-03-25 14:54:25 · 244 阅读 · 0 评论 -
rexerse_string的实现
#includevoid reverse_string(char*str){ int n=0; char *p=str; char temp;//不改变string的位置,用p指向string while((*p++)!='\0') { n++; } if(n>1) { temp=str[0]; str[0]=str[n-1]; str[n-原创 2015-03-25 14:07:41 · 361 阅读 · 0 评论 -
2014-12-26
#includeint main(){ int i; for(i=1000;i<=2000;i++) { if((i%4==0&&i%100!=0)||(i%400==0)) printf("%d\t",i); else continue; } return 0;}输出1000-2000之间的闰年,用逻辑运算符作为一个判断语句原创 2014-12-26 10:06:28 · 337 阅读 · 1 评论 -
循环队列函数实现
#pragma once#include#includeusing namespace std;#define MAXSIZE 20typedef int ElemType;typedef struct Queue{ ElemType *base; int front; int rear;}Queue;bool IsEmpty(Queue原创 2015-05-16 15:34:52 · 751 阅读 · 0 评论