一个简易的登陆程序

#include<stdio.h>#include<string.h>void login(char *p); main(){ char password[10]; login(password); printf("登陆成功!\n"); }void login(char *p){ char a[]="123"; /*密码假设为123*/ do { printf("输入密码:"); gets(p); } while(strcmp(a,p)!=0); }
2008-05-06 22:05 | 阅读 1879 次 | 评论 0 条

尾插法建立单链表及输出

#include<stdio.h>#include<stdlib.h>typedef struct node{int data;struct node *link;}LNode;LNode *createtail(){ LNode *s,*h,*r; int x,tag; printf("结束符号:"); scanf("%d",&amp;tag); h=(LNode *)malloc(sizeof(LNode)); r=h; printf("输入数据:"); scanf("%d",&amp;x); while(x!=tag) { s=(LNode *)malloc(sizeof(LNo...
2008-05-06 21:58 | 阅读 4786 次 | 评论 0 条

前插法建立单链表及输出

#include<stdio.h>#include<stdlib.h>typedef struct node{int data;struct node *link;}LNode;LNode *createfirst(){ LNode *s,*h; int x,tag; h=NULL; printf("结束符号:"); scanf("%d",&amp;tag); printf("输入数据:"); scanf("%d",&amp;x); while(x!=tag) { s=(LNode *)malloc(sizeof(LNode)); s->data=x; s->link=h; h=...
2008-05-06 21:52 | 阅读 3729 次 | 评论 0 条

输入一串字母,统计每个字母出现的次数,不区分大小写

#include<stdio.h>main(){ char ch[26]={0}; int a[26]={0},i; gets(ch); for(i=0;ch[i]!='\0';i++) { if('A'<=ch[i]&amp;&amp;ch[i]<='Z') a[ch[i]-'A']++; if('a'<=ch[i]&amp;&amp;ch[i]<='z') a[ch[i]-'A'-32]++; } for(i=0;i<26;i++) printf("%c:%d\t",i+65,a[i]); printf("\n");}
2008-04-28 21:59 | 阅读 1683 次 | 评论 0 条