易截截图软件、单文件、免安装、纯绿色、仅160KB

链表综合操作C版实现程序

决定找时间把数据结构复习下,从链表开始吧。这一知识点虽说并不涉及复杂的算法,不需要费尽头脑去思考来龙去脉,但是要写出完整的程序来,还是要花一些时间的。特别是如果对指针操作不够熟练,极易出错。好久没用C写程序了……
完整代码:
/*
* 单链表基本操作C版实现程序
* 包括插入、删除、查找。
*
* author: wensefu
* date: 10-5-4
*/
#include<stdio.h>
#include<stdlib.h>
/*单链表数据结构定义*/
typedef struct Node
{
int e; //这里简单点,以整型为结点数据域
struct Node * next;
}LNode,*LinkList;
/*相关函数声明*/
bool ListInit(LinkList); //初始化链表
bool ListInsert(int,int,LinkList); //插入 (注:C中没有bool类型)
bool ListDelete(int,LinkList); //删除指定位置结点
int GetElem(LinkList,int); //返回指定位置结点数据域的值
int GetLength(LinkList); //获取链表长度
void print(LinkList); //print
LinkList CreateList(); //建立一个空链表
int main()
{
printf("--------------------------------链表综合操作------------------------------\n\n");

/****先初始化*******/
LinkList l=CreateList();
if(ListInit(l))
{
printf("The linklist now is:>");
print(l);
}

/******执行操作**********/
bool flag=true;
int e,pos;
while(true)
{
if(flag==false)
{
break;
}
printf("请选择操作: 1.插入 2.删除 3.查找 4.退出>");

int choice;
while(true)
{
scanf("%d",&choice);
if(choice<1||choice>4)
{
printf("Input error,try again:>");
}
else
{
break;
}
}
switch(choice)
{
case 1:
printf("input elem and pos>");
scanf("%d%d",&e,&pos);
if(ListInsert(e,pos,l))
{
printf("Insert successful,now the linklist is: ");
print(l);
}
else
{
printf("Insert failed\n");
}
break;
case 2:
printf("input pos to delete>");
scanf("%d",&


相关文档:

C中读取数组

#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
main()
{
FILE *fp;
if ( (fp = fopen( "c:\\a.txt", "r" )) == NULL ) printf("ERROR!\n");
int tmp[MAXSIZE];
int i;
for ( i=0; i<MAXSIZE; i++ )
{
tmp[i] = 0; ......

memcached 与c/c++运用

修改makefile,在LIBS里面加上-lmemcached,比如原来 gcc test.c,现在 gcc test.c -lmemcached。这个库就是libmemcached提供的。
然后添加#include<libmemcached/memcached.h>,这个文件也是libmemcached提供的。
主函数里面需要添加:
    memcached_st *memc;
    uint32_t&nbs ......

如何理解c和c++ 的复杂类型声明

曾经碰到过让你迷惑不解、类似于int * (* (*fp1) (int) ) [10];这样的变量声明吗?本文将由易到难,一步一步教会你如何理解这种复杂的C/C++声明。
  我们将从每天都能碰到的较简单的声明入手,然后逐步加入const修饰符和typedef,还有函数指针,最后介绍一个能够让你准确地理解任何C/C++声明的“右左法则”。 ......

【转】C/C++ 笔试、面试题目大汇总


1.求下面函数的返回值(微软)
int func(x)
{
    int countx = 0;
    while(x)
    {
          countx ++;
          x = x&(x-1);
    ......

两个矩阵相乘并输出的C程序

[root@ocsser file]# cat array-05.c
//this is a program for two juzheng xiangcheng.
#include <stdio.h>
int main(){
        int i,j,m,n;
        int g,k,f;
        int c[5][6];
 & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号