随笔分类 -  C

摘要:#include "stdio.h" #include "malloc.h"#define maxsize 100typedef int datatype;typedef struct node { datatype data; struct node *Lchild,*Rchild; }BTNode;void CreateBTNode(BTNode *&b,char *str) { struct node *st[maxsize],*p=NULL; int top=-1,k,j=0; char ch; b=NULL; ch=str[j]; wh 阅读全文
posted @ 2013-09-30 11:24 露水上的青蛙 阅读(253) 评论(0) 推荐(0)
摘要:#include "stdafx.h"char stack[512];int top=0;void push(char c){stack[top]=c;top++;}char pop(void){top--;return stack[top];}int is_empty(void){return top==0;}int _tmain(int argc, _TCHAR* argv[]){ push('a');push('b');push('c');while(!is_empty()){putchar(pop());putchar 阅读全文
posted @ 2013-09-23 18:08 露水上的青蛙 阅读(357) 评论(0) 推荐(0)
摘要:int i,j,t;int a[5]={12,4,12342,32,10}; for(i=1;i=0&&a[j]>t;j--) a[j+1]=a[j]; a[j+1]=t;}for (i=0;i<5;i++){printf("%d ",a[i]);} 阅读全文
posted @ 2013-09-22 19:15 露水上的青蛙 阅读(200) 评论(0) 推荐(1)
摘要:gcc是linux c编译器gcc -o o指定文件名或者会生成a.out文件comment 注释generate(生成) some simple ouput使用标准 为C89 阅读全文
posted @ 2013-09-22 18:25 露水上的青蛙 阅读(226) 评论(0) 推荐(1)
摘要:教室里有编号为1~50的电灯50盏,现全部处于关闭状态。六(一)班则好有50名同学,现依次进入教室,第一个同学将所有电灯都拉一下,第二个同学将编号为2的倍数的电灯各拉一下,第三个同学将编号为3的倍数的电灯各拉一下……,依此类推,直到最后一个同学操作完毕后,教室里共有几盏灯是亮着的?首先想到的是定义一个结构体typedef struct student{int a;bool flag;};第一种实现方式 结构体数组struct student st[50];int i,j=1,m;for (i=0;ia[i]=i+1; st->flag[i]=0;//0灯全部熄灭}//50个学生轮流关灯f 阅读全文
posted @ 2013-09-22 14:44 露水上的青蛙 阅读(361) 评论(0) 推荐(0)
摘要:上大学的时候一直在使用win_tc就因为使用方便,今天准备用这个工具编辑一个函数,就特意下载了一个。没想到直接出来一个bug。sizeof(char*)结果竟然是2.果断接卸,误人子弟啊。 阅读全文
posted @ 2013-09-22 10:47 露水上的青蛙 阅读(266) 评论(0) 推荐(0)
摘要:#include "stdio.h"#include "string.h"#include "stdlib.h"//#include typedef int ElemType;/* 创建链表式栈结构体*/typedef struct Stack_Node{ ElemType data; struct Stack_Node *next;}stack_node;/* 初始化栈*/stack_node* initStack(){struct Stack_Node *top;top=(struct Stack_Node*)malloc(siz 阅读全文
posted @ 2013-09-18 15:29 露水上的青蛙 阅读(537) 评论(0) 推荐(0)
摘要:#include "stdio.h"#include "string.h"#include "stdlib.h"//#include #define stack_size 2 //定义栈的初始化空间大小#define stack_add_size 3typedef int ElemType;typedef struct sqstack{ElemType *top;ElemType *bottom;int stacksize;//记录当前已分配的空间}sqStack;sqStack initStack(){sqstack s;s.bot 阅读全文
posted @ 2013-09-18 14:45 露水上的青蛙 阅读(356) 评论(0) 推荐(0)
摘要:#include "stdio.h"#include "string.h"void main(){int a[6];int j=0,tmp,i,t;memset(a,0,sizeof(a));while(1){if(j!=6){printf("请任意输入一个整数:");scanf("%d",&tmp);a[j]=tmp;j++;}else{printf("请任意输入一个整数---删除:");scanf("%d",&tmp);for (i=0;i<j;i+ 阅读全文
posted @ 2013-09-17 16:35 露水上的青蛙 阅读(116) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include "stdio.h"#include using namespace std;#define MAXSIZE 50#define swap(a,b) a=a+b;b=a-b;a=a-b;typedef struct Node{int data;struct Node *next;}LNode;void Output(Node *p);void TailOutput(LNode *p);// 头插入法建链表LNode* HeadList(LNode *head){int i;LNode *p,*h;h 阅读全文
posted @ 2013-09-13 18:11 露水上的青蛙 阅读(159) 评论(0) 推荐(0)
摘要:#include "stdafx.h"static int a;int display(int m){static int b=2;//静态局部变量在编译时赋初值,即只赋值一次。运行设置断点可以检验//int b=0;//函数调用时赋值,必须初始化b = b + m;return b;}int _tmain(int argc, _TCHAR* argv[]){ int c; a = 3; printf("%d\n",a); c = display(a); printf("%d\n",c); c = display(a); printf 阅读全文
posted @ 2013-09-11 15:07 露水上的青蛙 阅读(177) 评论(0) 推荐(0)
摘要:创建文件夹mkdir 文件夹名称删除文件夹rm -rf 文件夹名称创建文件touch test.c删除文件rm -f test.c编译gcc -o test test.c在执行只语句后会生成一个*test运行./testesc+i 插入esc+x 删除一个字符 阅读全文
posted @ 2013-09-10 16:23 露水上的青蛙 阅读(131) 评论(0) 推荐(0)
摘要:1. 形参和实参调用函数时,写在括号里面的就是实参,函数本身用的就是形参。2.字符串问题char a[5]={"abcd"};注意是4个字符,而不是5个 字符串数组后面带'\0'char b[5];b[0]='a'.....b[4]='e'; 字符数组是没有的3.atoi实现intatoi(char *s){ int sign=1,m=0; if(*s=='+'||*s=='-') sign=(*s++=='+')?1:-1; while(*s!='\0'){ m 阅读全文
posted @ 2013-09-09 12:01 露水上的青蛙 阅读(206) 评论(0) 推荐(0)
摘要:#include #include "malloc.h"using namespace std;typedef struct BTNode{char data;struct BTNode *Lchild,*Rchild;}BTNode;struct BTNode *lpRoot,*temp;void visit(char a){printf("%c\n",a);}//先序遍历的递归算法void PreorderTraverse(BTNode *T){if (T!=NULL){coutdata;PreorderTraverse(T->Lchild); 阅读全文
posted @ 2013-09-03 16:26 露水上的青蛙 阅读(165) 评论(0) 推荐(0)
摘要:#includeEXEC SQL INCLUDE SQLCA;void insert (char password_[6],char id_[20],int balance_){ EXEC SQL BEGIN DECLARE SECTION; VARCHAR user[20],pass[20],tnsname[20]; char password[6]; char id[20]; int balance; EXEC SQL END DECLARE SECTION; strcpy(user.arr,"zhangsan"); user.len=(unsigned short)s 阅读全文
posted @ 2013-09-03 15:05 露水上的青蛙 阅读(313) 评论(0) 推荐(0)
摘要:◆经典C源程序100例:http://post.baidu.com/f?kz=8618367 ◆时钟的驻留程序:http://post.baidu.com/f?kz=10822377 ◆数据结构暨若干经典问题和算法:http://post.baidu.com/f?kz=10922856 ◆LIUXUY 磁盘系统源程序:http://post.baidu.com/f?kz=12973347 ◆RLE压缩:http://post.baidu.com/f?kz=12592570 ◆快速排序:http://post.baidu.com/f?kz=12262349 ◆全排列的递归... 阅读全文
posted @ 2013-08-26 16:16 露水上的青蛙 阅读(324) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include "stdio.h"#include "string.h"struct persion{int Height;int power;int Iq;};typedef struct persion Boy;void InitBoy(Boy *boys){boys[0].Height=172;boys[0].power=90;boys[0].Iq=80;boys[1].Height=162;boys[1].power=97;boys[1].Iq=70;boys[2].Height=182 阅读全文
posted @ 2013-08-26 10:41 露水上的青蛙 阅读(138) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include "stdio.h"#include "string.h"#define count 13struct baby{int position; //定义小伙伴的位置struct baby *next;};int _tmain(int argc, _TCHAR* argv[]){ struct baby gamer[count];//初始化小伙伴 组成一个循环链表for (int i=0;inext!=first){temp=first;for (int i=1;inext;}firs 阅读全文
posted @ 2013-08-21 10:46 露水上的青蛙 阅读(202) 评论(0) 推荐(0)
摘要:1. 安装oralce 10g2.建立数据库和用户配置VS2005环境 proc需要嵌入式环境在C/C++常规里面加入D:\oracle\product\10.2.0\db_1\precomp\public在连接器附加库目录里加入D:\oracle\product\10.2.0\db_1\precomp\LIB然后编译在dos环境下生产的conn.c#include #include #include #include"sqlca.h" EXECSQLBEGINDECLARESECTION;char*uid=batman/batman@gexin;EXECSQLENDDEC 阅读全文
posted @ 2013-08-16 17:32 露水上的青蛙 阅读(2435) 评论(0) 推荐(0)
摘要:oracle数据库开发编程中,没有找到oci.dll,一般是系统的 path 设置有问题, 查找oci.dll, 然后加入到系统路径。oci.dll 可下载解压到系统盘的system32目录下。然后打开“开始-运行-输入regsvr32 oci.dll”,回车即可解决错误提示! 阅读全文
posted @ 2013-08-16 13:49 露水上的青蛙 阅读(1161) 评论(0) 推荐(0)