c经典链表程序
#include "stdio.h"
#include "malloc.h"
typedef int elemtype;
struct node
{
elemtype data;
struct node *next;
};
typedef struct node NODE;
NODE * creat(NODE *head)
{
NODE *p,*q;
elemtype i;
head=(NODE*)malloc(sizeof(NODE));
scanf("%d",&(head->data));
p=head;
while(p->data!=0)//0为结束符
{
q=(NODE*)malloc(sizeof(NODE));
scanf("%d",&(q->data));
p->next=q;
p=q;
}
p->next=NULL;
return head;
}
void printlist(NODE *head)
{
NODE *p;
elemtype i=0;
p=head;
while(p->next!=NULL)
{
printf("the %d node\n",i);
i++;
printf("%d\n",p->data);
p=p->next;
}
printf("\n");
}
void main(void)
{
NODE *my_head;
my_head=(NODE *)malloc(sizeof(NODE));
my_head=creat(my_head);
printlist(my_head);
//getch();
}
相关文档:
assert
函数名: assert
功 能: 测试一个条件并可能使程序终止
用 法: void assert(int test);
程序例:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct ITEM {
int&n ......
// backlightDlg.cpp : implementation file
//
#include "stdafx.h"
#include "backlight.h"
#include "backlightDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CbacklightDlg dialog
CbacklightDlg::CbacklightDlg(CWnd* pParent /*=NULL*/)
: CDialog(CbacklightDlg::IDD, pParent)
{
......
#include "draw.h"
#include "ui_draw.h"
#include <QPixmap>
draw::draw(QWidget *parent)
: QDialog(parent), ui(new Ui::draw)
{
ui->setupUi(this);
// this->setWindowFlags( Qt::FramelessWindowHint);
ctrlPoint.s ......
C和C++编程和学习文档
1 :指针变量名称以p为首字符,这是程序员通常在定义指针时的一个习惯
2 :har * p; (int *)p 把p强制转换为int型   ......
n 用标识符代表一个常量,称为符号常量。 n 符号常量与变量不同,它的值在其作用域内不能改变,也不能再被赋值。 n 使用符号常量的好处是: Ø 含义清楚; Ø 能做到“一改全改”。 --话说:不知道c里面有没有全局变量的东东,有的话,这两个的实际用处有啥子区别呢?看看再说 数据结构+算法=程序 终于知道这 ......