libmysql.dll 在安装mysql 的\mysql-5.6.22-win32\lib目录下。
你的二分法查找的C语言程序有两租念处问题,我帮你改弊颂困好了(改樱型动的地方见注释)
#include <stdio.h>
#include <math.h>
void main(){//这里把mian改成main
int a[10]={0,1,6,16,23,56,80,100,110,115}
int low,high,mid,found,n
low=0
high=9
found=0
printf("write a number:\n")
do{
scanf("%d",&n)
getchar()
}while(n<a[0]||a[9]<n)//这里把n小于a[9]改成a[9]小于n
while(low <= high){
mid=(low+high)/2
if(n==a[mid]){
found=1
break
}else if(a[mid]>n)
high=mid-1
else
low=mid+1
}
if(found==1){
printf("this number bit is %d\n",mid)
}else{
printf("NO no %d\n",n)
}
}
我将你的程序格式进行了修改,随便提醒一下,你的程序有格式,但不够规范。我改后是否觉得读起来顺畅一些,我的原则,没有好的格式,哗樱你成不了好的程序员。#include#include#include#include#include#definePT"工号:%ld姓名:%s基本工资:%0.2f补贴金额:%0.2f奖励金额:%0.2f扣除金额:%0.2f\n",gz->num,gz->name,gz->baswages,gz->allowance,gz->reward,gz->deduct#defineNsizeof(structInfo)structInfo*headtypedefstructInfo{longnumcharname[25]floatbaswagesfloatallowancefloatrewardfloatdeductfloatrealitystructInfo*next}typevoidLogoIn(){printf("\t\t\t/--------------------------------\\\n")printf("\t\t\t|----欢迎使用员工工资管理系统----|\n")printf("\t\t\t/--------------------------------\\\n")}voidLogoOut(){printf("\t\t\t/--------------------------------\\\n")printf("\t\t\t|----感谢使用员工工资管理系统----|\n")printf("\t\t\t/--------------------------------\\\n")printf("\t\t\t\t\t\t制作人:软件0903谢松均\n")printf("\t\t\t\t\t\t完成日期:2010年09月25日\n")}structInfo*add(void){type*p1,*p2head=p2=(type*)malloc(N)p1=(type*)malloc(N)printf("|员工号|姓名|基本工资|补贴金额|奖励金额|扣除金额|\n")scanf("%ld%s%f%f%f%f",&p1->num,p1->name,&p1->baswages,&p1->allowance,&p1->reward,&p1->deduct)while(p1->num!=0){p2->next=p1p2=p1p1=(type*)malloc(N)scanf("%ld%s%f%f%f%f",&p1->num,p1->name,&p1->baswages,&p1->allowance,&p1->reward,&p1->deduct)}p2->next=NULLfree(p1)returnhead}voidScreenOut(type*gz){gz=gz->nextwhile(gz!=NULL){printf(PT)gz=gz->next}}structInfo*find(type*gz)//这里的函数类型最好是逻辑型,成功返回真,否则返回假{intchooselongnumchars[25]printf("请选择查询方式:\n(1):姓名查询\n(2):工号查询\n")scanf("%d",&choose)switch(choose){case1:{printf("请输入对方的姓名:")scanf("%s",s)while(gz->next!=NULL){if((strcmp(s,gz->name))==0){printf(PT)returngz}}printf("\n没找到!\n")//返回乱锋丛???system("cls")}eakcase2:printf("请输入对方的工号:")scanf("%ld",&num)while(gz->next!=NULL){gz=gz->nextif(gz->num==num){printf(PT)returngz}}printf("\n没找到!\n")//返回???system("cls")eak}return0//对于 *** 作失败,需要你返回对应代码?}voidalter(type*gz){intchooselongnumcharname[25]floatbaswagesfloatallowancefloatrewardfloatdeductgz=find(head)printf("请选择基纳你想修改的内容:1.工号2.姓名3.基本工资4.补贴金额5.奖励金额6.扣除金额\n")scanf("%d",&choose)switch(choose){case1:printf("请输入你想修改的工号:")scanf("%ld",&num)gz->num=numprintf("\n修改后该员工的资料为:")printf(PT)eakcase2:printf("请输入你想修改的姓名:")scanf("%s",name)strcpy(gz->name,name)printf("\n修改后该员工的资料为:")printf(PT)eakcase3:printf("请输入你想修改的基本工资:")scanf("%f",&baswages)gz->baswages=baswagesprintf("\n修改后该员工的资料为:")printf(PT)eakcase4:printf("请输入你想修改的补贴金额:")scanf("%f",&allowance)gz->allowance=allowanceprintf("\n修改后该员工的资料为:")printf(PT)eakcase5:printf("请输入你想修改的奖励金额:")scanf("%f",&reward)gz->reward=rewardprintf("\n修改后该员工的资料为:")printf(PT)eakcase6:printf("请输入你想修改的扣除金额:")scanf("%f",&deduct)gz->deduct=deductprintf("\n修改后该员工的资料为:")printf(PT)eakdefault:printf("输入有误,按任意键退出!")getch()system("cls")eak}}structInfo*del(type*gz)//这里同上?你看{type*pintchooselongnumcharc,s[25]p=gz->nextprintf("请选择查询方式:\n(1):姓名查询\n(2):工号查询\n")scanf("%d",&choose)switch(choose){case1:printf("请输入对方的姓名:")scanf("%s",&s)while(p!=NULL){if((strcmp(s,p->name))==0){printf("信息已找到")printf("是否要删除此条信息?是回'Y',不是回'N'。\n")c=getch()if(c=='Y'&&c=='y'){gz->next=p->nextfree(p)returngz}elseprintf("没找到!")}}eakcase2:printf("请输入对方的工号:")scanf("ld",&num)while(p!=NULL){if(p->num==num){printf("信息已找到")printf("是否要删除此条信息?是回'Y',不是回'N'。\n")c=getch()if(c=='Y'&&c=='y'){gz->next=p->nextfree(p)returngz}elseprintf("没找到!")}}eak}return0//对于 *** 作失败,需要你返回对应代码?}voidScreenIn(void){intchooseprintf("功能选项:1.添加2.修改3.显示4.查找5.删除6.统计0.退出\n")printf("你的选择是:")scanf("%d",&choose)switch(choose){case1:{head=add()printf("添加已结束\n")printf("请按任意键继续")getch()system("cls")}eakcase2:alter(head)printf("修改已结束")printf("请按任意键继续")getch()system("cls")eakcase3:ScreenOut(head)printf("信息已全部显示")printf("请按任意键继续")getch()system("cls")eakcase4:find(head)printf("查找已结束")printf("请按任意键继续")getch()system("cls")eakcase5:del(head)printf("删除已结束")printf("请按任意键继续")getch()system("cls")eakcase6:case0:system("cls")LogoOut()exit(1)eakdefault:printf("非法字符\n")printf("请按任意键继续\n")getch()system("cls")eak}}voidmain(){while(1){LogoIn()ScreenIn()}}欢迎分享,转载请注明来源:内存溢出
评论列表(0条)