| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3803 人关注过本帖
标题:[绝对原创]会c的怎能不看
只看楼主 加入收藏
takashi
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2004-6-28
收藏
得分:0 

忘了说了,自己得在相同目录下先创建一个mima.txt

密码可以自己设定。

2004-06-28 13:21
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 

挺有意思


qq:69558139
2004-06-30 18:00
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 

这个是经过重新休整后的程序了 更新了验证密码的代码 本来还想把管理系统的主体也改成验证密码的样式 但是工作就显得庞大多了 以后再弄把 下面这个程序经过win-tc windows98 系统成功执行

#include<stdio.h>

#include<graphics.h>

#include<conio.h>

#include<string.h> /* 需要解决的问题 各个模块的非法输入操作 */

#define N 100

typedef struct

{

char name[10]; /* 学生 人名 数学 英语 中文 */

int math,english,china;

}ST;

int king=0;

bye()

{

bar(155,225,445,255);

rectangle(150,220,450,260);

setcolor(BLACK);

outtextxy(185,230,"The Register code is wrong!");

outtextxy(205,240,"your c: will be format!");

getch();

game();

}

mywrong()

{

king++;

cleardevice();

if(king==3){ bye(); }

setfillstyle(1,RED);

bar(218,230,425,265);

rectangle(213,225,430,270);

setcolor(BLACK);

outtextxy(220,240," Invalid Password!");

outtextxy(220,250,"Press Any key to Continue.");

getch();

}

passwrd(char *p,char *w)

{

char *s,*t;

int key=0,n=0,gd=DETECT,gm=0;

registerbgidriver(EGAVGA_driver);

initgraph(&gd,&gm,"");

setcolor(RED);

rectangle(160,230,440,250);

outtextxy(200,235,"welcome to this program!"); getch();

cleardevice();

rectangle(160,230,440,250);

outtextxy(170,235,"you must input Register the code!"); getch();

while(key!=3)

{

cleardevice();

setcolor(RED);

rectangle(160,230,440,250);

outtextxy(170,235,"please input code for my name:");

rectangle(250,300,350,320); gotoxy(33,20);

while(n<12&&(s[n++]=getch())!=13)

if(s[n-1]==8){ if(n==1)n--; else { gotoxy(wherex()-1,20); printf(" "); n--; printf("%c",s[n]); n--; } }

else printf("*");

s[--n]='\0';

cleardevice();

rectangle(160,230,440,250);

outtextxy(170,235,"please input code for my QQ: ");

rectangle(250,300,350,320); gotoxy(33,20);

n=0;

while(n<12&&(t[n++]=getch())!=13)

if(t[n-1]==8){ if(n==1)n--; else { gotoxy(wherex()-1,20); printf(" "); n--; printf("%c",t[n]); n--; } }

else printf("*");

t[--n]='\0';

if(strlen(s)!=10&&strlen(t)!=8){ key++; mywrong(); continue; }

for(n=2;p[n]!='\0';n++){ p[n]=p[n]&n; w[n-2]=w[n-2]|n; }

if(s[0]==p[0]&&s[1]==p[1])for(n=2;s[n]!='\0';n++)if((s[n]&n)!=p[n]){ key++; mywrong(); continue; }

for(n=0;t[n]!='\0';n++)if((t[n]|(n+2))!=w[n]){ key++; mywrong(); continue; }

break;

}

if(key==3)bye();

cleardevice();

rectangle(160,230,440,250);

outtextxy(235,235,"password right");

getch();

closegraph();

}

int main()

{

ST s[N];

int i=1,j; /* j 是 当前已占有数据的人数*/

char *p="changstone",*w="43334708";

textbackground(1);

passwrd(p,w);

clrscr();

j=total(s); /* 每次启动程序 先更新数据 */

while(i)

{ clrscr();

printf("\n\t\t********************************\n");

printf("\t\t* input 1 is write data! *\n"); /* 写入数据 */

printf("\t\t* input 2 is change data! *\n"); /* 修改数据 */

printf("\t\t* input 3 is a person average! *\n"); /* 计算一个学生的平均成绩 */

printf("\t\t* input 4 is our average! *\n"); /* 计算全班单科平均成绩 */

printf("\t\t* input 5 is look data! *\n"); /* 查看 数据 */

printf("\t\t* input 6 is del data! *\n"); /* 删除数据 */

printf("\t\t* input 7 is Search data! *\n"); /* 这个是索引 */

/* printf("\t\t* input 9 is break the data! *\n"); */ /* 这个是 刷新数据 */

printf("\t\t* input 8 is game! *\n");

printf("\t\t* input 0 is exit! *\n"); /* 退出 */

printf("\t\t********************************\n");

printf("please input your select: ");

fflush(stdin);

i=myerror();

switch(i) /* 这些是 上面数字所对应的各个模块 */

{

case 1:j=mywrite(s,j);break; /* 写入数据 */

case 2:change(s);break; /* 修改数据 */

case 3:perave(s);break; /* 计算一个学生的平均成绩 */

case 4:ourave(s,j);break; /* 计算全班单科平均成绩 */

case 5:j=outdata(s);break; /* 查看 数据 */

case 6:j=del(s);break; /* 删除数据 */

case 7:myindex(s,j);break; /* 数据索引 */

case 8:game();

case 9:j=total(s);break; /* 刷新数据 */

}

}

printf("thank you for use this program!");

getch();

return 0;

}

total(ST *s) /* 刷新数据 模块*/

{

FILE *fp;

int i=0;

if((fp=fopen("c:\\kern.txt","rb"))==NULL){ printf("you must write any data!"); getch(); return 0; }

fread(&s,sizeof(ST),1,fp);

while(!feof(fp))

{

i++;

fread(&s,sizeof(ST),1,fp);

}

fclose(fp);

printf("Break Over!They are %d students!",i);

getch();

return i;

}

outdata(ST *s) /* 查看 数据 模块*/

{

FILE *fp;

int i=0;

clrscr();

if((fp=fopen("c:\\kern.txt","rb"))==NULL){ printf("you must write any data!"); exit(0); }

fread(&s[i],sizeof(ST),1,fp);

while(!feof(fp))

{

printf("\nNO.%d: ",i+1);

printf("name is: %s\n",s[i].name);

printf("math score: %d\n",s[i].math);

printf("english score: %d\n",s[i].english);

printf("china score: %d\n\n",s[i].china);

i++;

if(!(i%4))getch();

fread(&s[i],sizeof(ST),1,fp);

}

if(i==0)printf("data is none\n");

fclose(fp);

getch();

return i;

} /* 写入数据 模块*/ mywrite(ST *s,int j)

{ FILE *fp;

char i='n';

if((fp=fopen("c:\\kern.txt","ab"))==NULL){ printf("fopen error!"); exit(0); }

if(j==0)system("attrib c:\\KERN.TXT +h");

while(i=='n'||i=='N')

{

printf("input student name:");

scanf("%s",s[j].name);

printf("input %s's math Score:",s[j].name);

scanf("%d",&s[j].math);

printf("inpust %s's english Score:",s[j].name);

scanf("%d",&s[j].english);

printf("inpust %s's china Score:",s[j].name);

scanf("%d",&s[j].china);

fwrite(&s[j],sizeof(ST),1,fp);

++j;

fflush(stdin);

i=myquit();

}

printf("write over!\n");

fclose(fp);

getch();

return j;

}

change(ST *s) /* 修改数据 模块*/

{

char ch='n';

int i,j;

while(ch=='n'||ch=='N')

{

j=outdata(s);

printf("input you need change's data number:");

scanf("%d",&i);

printf("name is: %s input change's data:",s[i-1].name);scanf("%s",s[i-1].name);

printf("math score: %d input change's data:",s[i-1].math);scanf("%d",&s[i-1].math);

printf("english score: %d input change's data:",s[i-1].english);scanf("%d",&s[i-1].english);

printf("china score: %d input change's data:",s[i-1].china);scanf("%d",&s[i-1].china);

indata(s,j);

fflush(stdin);

ch=myquit();

}

printf("change over!");

getch();

}

perave(ST *s) /* 计算一个学生的平均成绩 */

{

int i;

char ch='n';

float ave;

while(ch=='n'||ch=='N')

{

outdata(s);

printf("input you want look average number:");

scanf("%d",&i);

ave=(float)(s[i-1].math+s[i-1].english+s[i-1].china)/3;

printf("\n%s's average is %f\n\n",s[i-1].name,ave);

fflush(stdin);

ch=myquit();

}

}

ourave(ST *s,int j) /* 计算全班单科平均成绩 */

{

int i,n;

char ch='n';

float ave=0;

while(ch=='n'||ch=='N')

{

printf("math:1 english:2 china:3 input your choose number: ");

scanf("%d",&i);

switch(i)

{

case 1:for(n=0;n<j;n++)ave=ave+s[n].math;printf("\ngrade math average is: %f\n\n",ave/j);break;

case 2:for(n=0;n<j;n++)ave=ave+s[n].english;printf("\ngrade english average is: %f\n\n",ave/j);break;

case 3:for(n=0;n<j;n++)ave=ave+s[n].china;printf("\ngrade china average is: %f\n\n",ave/j);break;

}

fflush(stdin);

ch=myquit();

}

}

del(ST *s) /* 删除数据 模块*/

{

int i,j;

char ch='n';

while(ch=='n'||ch=='N')

{

j=outdata(s);

printf("choose your want to del number: ");

scanf("%d",&i);

for(;i<j;i++)

s[i-1]=s[i];

indata(s,--j);

fflush(stdin);

ch=myquit();

}

printf("del ok!\n");

getch();

return j;

}

indata(ST *s,int j) /* 当修改数据 和 删除数据时 用到的 写入文件模块 将修改后的数据从新写入文件 */

{

FILE *fp;

int i;

if((fp=fopen("c:\\kern.txt","wb"))==NULL){ printf("fopen error!"); exit(0); }

for(i=0;i<j;i++)

fwrite(&s,sizeof(ST),1,fp);

fclose(fp);

}

myindex(ST *s,int j) /* 数据索引 模块*/

{

int i,n,m=0;

char p[10],ch='n';

while(ch=='n'||ch=='N')

{

printf("1:name 2:math 3:english 4:china 5:exit \n");

printf("choose you want to Search for data: ");

scanf("%d",&i);

switch(i)

{

case 1:

printf("input student name:");

scanf("%s",p);

while(m<j)

{

if(*p==*(s[m].name))printf("%s math score:%d english score:%d china score:%d\n",s[m].name,s[m].math,s[m].english,s[m].china);

m++;

}

break;

case 2:

printf("input student math Score:");

scanf("%d",&n);

while(m<j)

{

if(n==s[m].math)printf("%s math score:%d english score:%d china score:%d\n",s[m].name,s[m].math,s[m].english,s[m].china);

m++;

}

break;

case 3:

printf("input student english Score:");

scanf("%d",&n);

while(m<j)

{

if(n==s[m].english)printf("%s math score:%d english score:%d china score:%d\n",s[m].name,s[m].math,s[m].english,s[m].china);

m++;

}

break;

case 4:

printf("input student china Score:");

scanf("%d",&n);

while(m<j)

{

if(n==s[m].china)printf("%s math score:%d english score:%d china score:%d\n",s[m].name,s[m].math,s[m].english,s[m].china);

m++;

}

break;

case 5:return;

}

fflush(stdin);

ch=myquit();

} printf("index over!");

getch();

}

myerror()

{

char ch;

ch=getchar();

fflush(stdin);

if(ch>='0'&&ch<='9')return ch-'0';

else if(ch=='\n'){ return 9; }

else{ printf("input error!"); getch(); exit(0); }

}

myquit()

{

char i;

printf("quit?(y\\n)");

scanf("%c",&i);

if(i!='y'&&i!='Y'&&i!='n'&&i!='N'){ printf("input error!"); getch(); exit(0); }

return i;

}

game()

{

int gdriver,gmode=0,i=1,j=1,n;

char *s="format c: /q\n";

/*gdriver=DETECT;

registerbgidriver(EGAVGA_driver);

initgraph(&gdriver,&gmode,""); */ cleardevice();

setbkcolor(BLACK);

setcolor(WHITE);

/*closegraph(); */

gotoxy(1,1);

printf("Microsoft Windows 2000 [Version 5.00.2195]\n");

printf("(C) 1985-2000 Microsoft Corp.\n\n");

printf("C:\>");

for(j=0;j<10;j++)delay(90000000);

for(n=0;s[n]!='\0';n++){delay(10000);printf("%c",s[n]);}

for(j=0;j<5;j++)delay(90000);

printf("The type of the file system is FAT32.\n");

printf("\n");

printf("WARNING, ALL DATA ON NON-REMOVABLE DISK\n");

delay(10000);

printf("DRVIE C: WILL BE LOST!\n");

delay(10000);

printf("Proceed with Format (Y/N)? ");

delay(10000);

printf("y\n");

delay(10000);

printf("verifying 5217M\n");

delay(10000);

for(i=1;i<=100;i++)

{

printf("%-2d percent completed",i);

gotoxy(1,11);

delay(900000000);

}

printf("Game Over!");

closegraph();

getch();

exit(0);

}


qq:69558139
2004-07-08 16:22
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 
大家给点意见把

qq:69558139
2004-07-08 16:23
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 

如果再有人敢说这个是刚刚学了两个礼拜的人写的,而且还是原创,那我就立马跑过去杀了他!!!!!!!!


淘宝杜琨
2004-08-04 23:21
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 
??

qq:69558139
2004-08-05 18:52
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
以下是引用takashi在2004-06-28 13:17:06的发言:

刚学了2个礼拜的C语言,第一次接触编程,别见笑。

也是学生查询系统,用最简单的构造编的。

希望能给点意见。

(以下省略上千字)

这难道是刚刚学了2个礼拜的人写出来的吗?!!!


淘宝杜琨
2004-08-06 00:24
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 
袄 你说他的程序呀 呵呵 真是刚学了两个礼拜c写出来的? 那真厉害了~ 除非以前有编程的基础 那学两个礼拜c就编写出来是很正常地了

qq:69558139
2004-08-06 18:07
忆楠
Rank: 1
等 级:新手上路
帖 子:721
专家分:0
注 册:2004-7-5
收藏
得分:0 
我看完这里的帖子   鼠标的滚轮坏了````55555555555    楼主  赔我啊````!!!

点 鼠 标 , 救 饥 民 http://www./
2004-08-07 17:34
chengstone
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:562
专家分:226
注 册:2004-4-3
收藏
得分:0 
呵呵~~~  旧的不去新的不来嘛~~

qq:69558139
2004-08-08 13:06
快速回复:[绝对原创]会c的怎能不看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018211 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved