网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

c语言的look函数 c语言中lookup函数功能

LOOKUP函数匹配查找的数据不正确,求高手支招!

给两种方法:

成都创新互联公司是一家专注于成都做网站、网站设计与策划设计,类乌齐网站建设哪家好?成都创新互联公司做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:类乌齐等地区。类乌齐做网站价格咨询:028-86922220

1、用lookup函数,如果用lookup由数字查文字之前要

对文字一列进行升序排序。完成后就可以正确查找了

=LOOKUP(E1,$B$1:$B$3,$A$1:$A$3)

2、用vlookup方法,只提供方法,不做解释了。

不用排序。

=VLOOKUP(E1,IF({1,0},$B$1:$B$3,$A$1:$A$3),2,0)

C语言指针,函数连接两个字符串

看错原型了,重新修改如下,希望可以帮到你。

char*

str_cat(char

*src,

char

*dec,

int

n

)

//

不考虑src的数组溢出

{

char

*s

=

src;

while(*src++)//

找到src的结束位置,就是0结尾的地方

;

//

分号

while(n--){

//

在src的结束位置开始加入dec的字符,直到dec遇到0结束

*src

=

*dec++;

src++;

}

*src

=

0;

return

s;

}

求按要求用C语言作的一个计算器

计算器的c语言程序设计

一.功能概述:本程序能计算带二重括号的计算式的结果,如输入((3+2)*(3+2)+5)*((3+2)*(3+2)+5)*(5+5)= 将输出结果为9000

二.源程序:

#includestdio.h

int w;

double B[4][40];

shuru(char *pt)

{

int i=0,m;

do

{

*(pt+i)=getchar();

m=i;

i++;

}

while(*(pt+m)!='=');

*(pt+m)='+';

*(pt+m+1)='=';

}

tlchli(char *p)

{

int a,b;

if(*p=='-'||*p=='+')

{

for(b=0;*(p+b)!='=';b++)

;

for(;b=0;b--)

*(p+b+1)=*(p+b);

*p='0';

}

else

{

for(a=1;*(p+a)!='=';a++)

{

if(*(p+a)=='-'||*(p+a)=='+')

{

if(*(p+a-1)=='('*(p+a+1)='0'*(p+a+1)='9')

{

for(b=0;*(p+a+b)!='=';b++)

;

for(;b=0;b--)

*(p+a+b+1)=*(p+a+b);

*(p+a)='0';

a=(a+1);

}

}

}

}

}

jgh(double B[4][40],char *p)

{

int a,b,c=0,d,e,f,h,i,k,n,m;

double g=0,j=0;

for(a=0;a4;a++)

for(b=0;b40;b++)

B[a]=0;

for(d=0;*(p+d)!='=';d++)

{

if(*(p+d)=='+'||*(p+d)=='-'||*(p+d)=='*'||*(p+d)=='/')

{

if(*(p+d)=='+') B[3][c]='+';

if(*(p+d)=='-') B[3][c]='-';

if(*(p+d)=='*') B[3][c]='*';

if(*(p+d)=='/') B[3][c]='/';

if(*(p+d-1)==')'*(p+d-2)==')')

{

B[0][c]=')';

B[1][c]=')';

}

if(*(p+d-1)==')'*(p+d-2)!=')')

B[1][c]=')';

for(e=d-1;*(p+e)'0'||*(p+e)'9';e--)

;

for(f=e;*(p+f)!='.'(f0)*(p+f)='0'*(p+f)='9';f--)

;

if(*(p+f)=='.')

{

for(h=f-1;(h=0)*(p+h)='0'*(p+h)='9';h--)

;

h++;

if(*(p+h-1)=='('*(p+h-2)=='(')

{

B[0][c]='(';

B[1][c]='(';

}

if(*(p+h-1)=='('*(p+h-2)!='(')

B[1][c]='(';

for(i=h;*(p+i)='0'*(p+i)='9';i++)

g=(*(p+i)-48)+g*10.0;

for(k=f+1;*(p+k)='0'*(p+k)='9';k++)

;

k--;

for(n=k;*(p+n)='0'*(p+n)='9';n--)

j=(j/10.0+(*(p+n)-48)/10.0);

B[2][c]=(g+j);

g=j=0;

}

else

{

for(m=e;*(p+m)='0'*(p+m)='9';m--);

m++;

if(*(p+m-1)=='('*(p+m-2)=='(')

{

B[0][c]='(';

B[1][c]='(';

}

if(*(p+m-1)=='('*(p+m-2)!='(')

B[1][c]='(';

for(i=m;*(p+i)='0'*(p+i)='9';i++)

g=(*(p+i)-48)+g*10.0;

B[2][c]=g;

g=0;

}

c++;

}

}

w=(c-1);

}

qkh1(double B[4][40])

{

int a=1,b,c,d,e,f,j,k;

for(b=0;bw;b++)

{

if(B[a]=='(')

{

for(c=b;B[a][c]!=')';c++)

;

for(d=b+1;B[a][d]!='('dc;d++)

;

if(B[a][d]=='(')

k=d;

else

k=b;

B[a][k]=0;B[a][c]=0;

for(e=k;ec;e++)

{

if(B[3][e]=='*')

{

B[2][e+1]=B[2][e]*B[2][e+1];

if(B[3][e-1]=='-'(e0))

{

B[2][e]=0;

B[3][e]='-';

}

else

{

B[2][e]=0;

B[3][e]='+';

}

}

if(B[3][e]=='/')

{

B[2][e+1]=B[2][e]/B[2][e+1];

if(B[3][e-1]=='-'e0)

{

B[2][e]=0;

B[3][e]='-';

}

else

{

B[2][e]=0;

B[3][e]='+';

}

}

}

for(f=k;fc;f++)

{

if(B[3][f]=='+')

{

B[2][f+1]=B[2][f]+B[2][f+1];

B[2][f]=0;B[3][f]='+';

}

if(B[3][f]=='-')

{

B[2][f+1]=B[2][f]-B[2][f+1];

B[2][f]=0;B[3][f]='+';

}

}

b=c-1;

if(B[3][k-1]=='*'k0)

{

for(;kc;k++)

{

B[3][k]='*';

B[2][k]=1.0;

}

}

if(B[3][k-1]=='/'k0)

{

for(;kc;k++)

{

B[3][k]='/';

B[2][k]=1.0;

}

}

}

}

for(j=0;j=w;j++)

{

if(B[1][j]!='('B[1][j]!=')')

B[1][j]=B[0][j];

}

}

qkh2(double B[4][40])

{

int a,b,c,d,e,f,j;

for(b=0;bw;b++)

{

if(B[1]=='(')

{

for(c=b;B[1][c]!=')';c++)

;

B[1]=0;B[1][c]=0;

for(e=b;ec;e++)

{

if(B[3][e]=='*')

{

B[2][e+1]=B[2][e]*B[2][e+1];

if(B[3][e-1]=='-'(e0))

{

B[2][e]=0;

B[3][e]='-';

}

else

{

B[2][e]=0;

B[3][e]='+';

}

}

if(B[3][e]=='/')

{

B[2][e+1]=B[2][e]/B[2][e+1];

if(B[3][e-1]=='-'(e0))

{

B[2][e]=0;

B[3][e]='-';

}

else

{

B[2][e]=0;

B[3][e]='+';

}

}

}

for(f=b;fc;f++)

{

if(B[3][f]=='+')

{

B[2][f+1]=B[2][f]+B[2][f+1];

B[2][f]=0;B[3][f]='+';

}

if(B[3][f]=='-')

{

B[2][f+1]=B[2][f]-B[2][f+1];

B[2][f]=0;B[3][f]='+';

}

}

if(B[3][b-1]=='*'b0)

{

for(;bc;b++)

{

B[3]='*';

B[2]=1.0;

}

}

if(B[3][b-1]=='/'b0)

{

for(;bc;b++)

{

B[3]='/';

B[2]=1.0;

}

}

}

}

}

jshjg(double B[4][40])

{

int b,d,e,f;

for(e=0;ew;e++)

{

if(B[3][e]=='*')

{

B[2][e+1]=B[2][e]*B[2][e+1];

if(B[3][e-1]=='-'e0)

{

B[2][e]=0;

B[3][e]='-';

}

else

{

B[2][e]=0;

B[3][e]='+';

}

}

if(B[3][e]=='/')

{

B[2][e+1]=B[2][e]/B[2][e+1];

if(B[3][e-1]=='-'e0)

{

B[2][e]=0;

B[3][e]='-';

}

else

{

B[2][e]=0;

B[3][e]='+';

}

}

}

for(f=0;fw;f++)

{

if(B[3][f]=='+')

{

B[2][f+1]=B[2][f]+B[2][f+1];

B[2][f]=0;B[3][f]='+';

}

if(B[3][f]=='-')

{

B[2][f+1]=(B[2][f]-B[2][f+1]);

B[2][f]=0;B[3][f]='+';

}

}

}

shuchu(double B[4][40],char *p)

{

printf("answer %f\n",B[2][w]);

}

main()

{

char *p,A[100];

shuru(A);

p=A[0];

tlchli(p);

jgh(B,p);

qkh1(B);

qkh2(B);

jshjg(B);

shuchu(B,p);

}

#include"string.h"

#include"graphics.h"

#include"conio.h"

#include"dos.h"

#include"time.h"

#include"stdlib.h"

#include"stdio.h"

#include"math.h"

/*调用一系列的库函数*/

int py;/*定义一个全局变量*/

void mode(int py)/*mode函数,用来设置的,来使用计算器的多种运算功能*/

{ double x1,x2,ans,ans2;

if(py11)

{ printf("input x1,x2:");

scanf("%lf,%lf",x1,x2); }

else {printf("input x:");scanf("%lf",x1);}

switch(py)

{ case 6 : ans=x1+x2;printf("=%.3lf",ans);break;

case 7 : ans=x1-x2;printf("=%.3lf",ans);break;

case 8 : ans=x1*x2;printf("=%.3lf",ans);break;

case 9 : ans=x1/x2;printf("=%.3lf",ans);break;

case 10 : ans=pow(x1,x2);printf("x^%.1lf=%.3lf",x2,ans);break;

case 11 : ans=sqrt(x1);printf("=%.3lf",ans);break;

case 12 : ans=sin(x1);ans2=cos(x1);printf("sin x=%.3lf,cos x=%.3lf",ans,ans2);break;

case 13 : ans=asin(x1);ans2=acos(x1);printf("asin x=%.3lf,acos x=%.3lf",ans,ans2);break;

}

getch();clrscr();

}

int join(char *ps) /*join函数是输入用户名和密码的,可于已注册的用户进行匹配,注册用户可使用高级功能*/

{ char name[30],pass[20];

int len,i;

printf("ID:");

scanf("%s",name);

printf("\npass word:");

scanf("%s",pass);

clrscr();

for(i=0;istrlen(ps);i++)

if(pass[i]!=*(ps+i)) return 0;

return 1;

}

int menu(int pass)/*menu函数,菜单*/

{int py=6;char key=0;

gotoxy(1,4);

printf("MENU\n\n");

printf("ADD +\n");

printf("SUB -\n");

printf("MUL *\n");

printf("DIV /");

gotoxy(10,6);printf("-");

if(pass) {gotoxy(1,10);printf("INV ^\n");

printf("EVO ~\n");

printf("SIN COS\n");

printf("ASIN ACOS\n");

printf("modify\n");

printf("QUIT"); }

else {gotoxy(1,10);printf("QUIT");}

while(key!=13) /*以下都是控制选择箭头的位子的语句*/

{ key=getch();

switch(key)

{ case 80 : gotoxy(10,py);printf(" ");if(!pass) py=py%5+6; else {++py;if(py==16) py=6;}break;

case 72 : gotoxy(10,py);printf(" ");--py; if(py==5) py=10+5*pass; break;

}

gotoxy(10,py);printf("-");

}

return py;

}

main() /*主函数,关于函数分配和开始动画的语句*/

{ int gd=DETECT,gm,x=320,y=10,i,l=10,h=10,t,co=3,v=0;

int pass;

FILE *fp;char ps[20];

initgraph(gd,gm,"");/*初始化图形模式*/

registerbgidriver(EGAVGA_driver);

for(i=1;i31;co=(co++%10),v++,y+=2+v,i++)

{ delay(9e10);cleardevice();

setcolor(co);

setfillstyle(1,co);

sector(x,y,0,360,l,h);/*画圆*/

}

for(i=1;i300;i++)

{ setcolor(i%10);

circle(x,y,i);

delay(1000);/*延时*/

}

cleardevice();/*清屏*/

closegraph();

fp=fopen("file1","r");

if(fp==NULL) pass=1;

else {fgets(ps,20,fp);

pass=join(ps);}

ld: py=menu(pass);

if(py==pass*5+10) {clrscr();printf("bye bye!");getch();return 0;}

else if(py!=14){clrscr();mode(py);} else { fp=fopen("file1","w");

printf("\npass word:");

scanf("%s",ps);

fputs(ps,fp);

fclose(fp); getch();clrscr();

}

goto ld; /*函数内跳转*/

}

#include stdio.h /*库函数*/

struct s_node

{

int data;

struct s_node *next;

};

typedef struct s_node s_list;

typedef s_list *link;

link operator=NULL;

link operand=NULL;

link push(link stack,int value)

{

link newnode;

newnode=(link) malloc(sizeof(s_list));

if(!newnode)

{

printf("\nMemory allocation failure!!!");

return NULL;

}

newnode-data=value;

newnode-next=stack;

stack=newnode;

return stack;

}

link pop(link stack,int *value)

{

link top;

if(stack !=NULL)

{

top=stack;

stack=stack-next;

*value=top-data;

free(top);

return stack;

}

else

*value=-1;

}

int empty(link stack)

{

if(stack==NULL)

return 1;

else

return 0;

}

int is_operator(char operator)

{

switch (operator)

{

case '+': case '-': case '*': case '/': return 1;

default:return 0;

}

}

int priority(char operator)

{

switch(operator)

{

case '+': case '-' : return 1;

case '*': case '/' : return 2;

default: return 0;

}

}

int two_result(int operator,int operand1,int operand2)

{

switch(operator)

{

case '+':return(operand2+operand1);

case '-':return(operand2-operand1);

case '*':return(operand2*operand1);

case '/':return(operand2/operand1);

}

}

void main()

{

char expression[50];

int position=0;

int op=0;

int operand1=0;

int operand2=0;

int evaluate=0;

printf("\nPlease input the inorder expression:");

gets(expression);

while(expression[position]!='\0'expression[position]!='\n')

{

if(is_operator(expression[position]))

{

if(!empty(operator))

while(priority(expression[position])= priority(operator-data)

!empty(operator))

{

operand=pop(operand,operand1);

operand=pop(operand,operand2);

operator=pop(operator,op);

operand=push(operand,two_result(op,operand1,operand2));

}

operator=push(operator,expression[position]);

}

else

operand=push(operand,expression[position]-48);

position++;

}

while(!empty(operator))

{

operator=pop(operator,op);

operand=pop(operand,operand1);

operand=pop(operand,operand2);

operand=push(operand,two_result(op,operand1,operand2));

}

operand=pop(operand,evaluate);

printf("The expression [%s] result is '%d' ",expression,evaluate);

getch();

}

c语言学生管理系统学生成绩管理系统 功能: 每个学生信息为一个记录,包括学号,姓名,性别,3 门课程成绩

#include"stdio.h"

#include"conio.h"

#include"string.h"

#include"stdlib.h"

void look(); /*声明查看函数*/

void save(); /*声明保存函数*/

void search_name(); /*声明按姓名查看函数*/

void search_number(); /*声明按学号查看函数*/

void order(); /*声明排序函数*/

void del(); /*声明删除函数*/

int openl(); /*声明打开函数*/

void welcome(); /*声明我的个人信息函数*/

void type(); /*声明输入函数*/

void see(); /*声明打开并查看文件函数*/

struct student /*定义学生信息的结构体类型*/

{

char num[15]; /*学号*/

char name[20]; /*姓名*/

char sex[4]; /*性别*/

int english; /*英语成绩*/

int math; /*数学成绩*/

int chinese; /*语文成绩*/

float aver; /*平均成绩*/

float sum; /*总成绩*/

}stu[100];

int n; /*声明一个全局变量*/

void main() /*主函数即用户的操作界面*/

{

system("color 1E"); /*设计文本颜色*/

int b,flag=0; /*声明局部变量*/

while(1) /*循环输出以下信息*/

{

printf("\n\t\t\t欢迎来到学生成绩管理系统!\n");

printf("\n\t\t\t\t ###制作\n");

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

printf("\t\t\t1.键入学生的信息\n\n"); /*键入学生的信息*/

printf("\t\t\t2.查看录入的学生信息\n\n"); /*查看录入的学生信息*/

printf("\t\t\t3.按姓名查看学生的信息\n\n"); /*按姓名查看学生的信息*/

printf("\t\t\t4.按学号查看学生的信息\n\n"); /*按学号查看学生的信息*/

printf("\t\t\t5.按平均成绩排序\n\n"); /*排序*/

printf("\t\t\t6.删除学生信息\n\n"); /*删除学生信息*/

printf("\t\t\t7.保存学生信息\n\n"); /*保存*/

printf("\t\t\t8.打开文件\n\n"); /*打开文件*/

printf("\t\t\t9.我的个人信息\n\n"); /*我的个人信息*/

printf("\t\t\t0.退出\n\n"); /*退出*/

printf("\t\t\t请输入你的选择:");

scanf("%d",b);

switch(b)

{

case 1:type();break; /*调用键入学生信息函数*/

case 2:look();break; /*调用查看函数*/

case 3:search_name();break; /*调用姓名查看函数*/

case 4:search_number();break; /*调用学号查看函数*/

case 5:order();break; /*调用排序函数*/

case 6:del();break;/*调用删除函数*/

case 7:save();break;/*调用保存函数*/

case 8:see();break;/*调用打开文件函数*/

case 9:welcome();break;/*调用我的个人信息函数*/

case 0:flag=1;break;/*退出SWITCH语句*/

default :printf("错误!");

}

if(flag) break; /*如果选择0就退出循环*/

}

}

void welcome() /*我的个人信息函数*/

{

system("CLS");

printf("\n\n\t\t------------个人信息------------"); /*在屏幕上输出一下信息*/

printf("\n\n\n\n\t\t姓名:###");

printf("\t\t\tSex:#\n");

printf("\t\t年龄:#\n");

printf("\n\t\t\t--------学习经历--------\n\n\n");

printf("\t\t小学:######\n\n");

printf("\t\t初中:#####\n\n");

printf("\t\tS高中:######\n\n");

printf("\t\t大学:######\n\n");

printf("\n\n\t\t按任意键返回欢迎屏幕!");

getch(); /*按任意键返回主函数*/

}

void type() /*定义键入学生信息函数*/

{

system("CLS");

int i; /*定义局部变量*/

printf("\t\t输出你想输入的学生信息个数:");

scanf("%d",n);

for(i=0;in;i++) /*输入每个学生的信息*/

{

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

printf("\t\t\t学号:");

scanf("%s",stu[i].num); /*输入学号*/

printf("\t\t\t姓名:");

scanf("%s",stu[i].name); /*输入姓名*/

printf("\t\t\t性别:");

scanf("%S",stu[i].sex); /*输入性别*/

printf("\t\t\t英语:");

scanf("%d",stu[i].english); /*输入英语成绩*/

printf("\t\t\t数学:");

scanf("%d",stu[i].math); /*输入数学成绩*/

printf("\t\t\t语文:");

scanf("%d",stu[i].chinese); /*输入语文成绩*/

stu[i].aver=((float)stu[i].english+(float)stu[i].math+(float)stu[i].chinese)/3;/*计算平均成绩*/

stu[i].sum=(float)stu[i].english+(float)stu[i].math+(float)stu[i].chinese;/*计算总成绩*/

printf("\t\t\t平均成绩=%4.1f\n",stu[i].aver); /*输出平均成绩*/

printf("\t\t\t总成绩=%4.1f\n",stu[i].sum); /*输出总成绩*/

}

printf("\n\n\t\t\t按任意键返回菜单!!");

getch();

save();

}

void save() /*建立保存文件函数*/

{

system("CLS");

FILE *fp; /*定义文件型指针*/

int i;

if((fp=fopen("student.txt","wb"))==NULL) /*打开输出文件*/

{

printf("不能打开文件!\n");

return; /*终止程序*/

}

for(i=0;in;i++) /*向student文件中写入信息*/

if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)

printf("文件写入错误\n");

fclose(fp); /*关闭文件*/

printf("\n\n\n\n\t\t\t学生信息保存成功!\n");

printf("\n\n\n\n\t\t\t按任意键返回菜单!!");

getch();

}

void look() /*定义查看函数*/

{

system("CLS");

int i;

//n=openl(); /*调用openl函数*/

printf("\t学号\t姓名\t性别\t英语\t数学\t语文\t平均成绩\t总成绩\n");

for(i=0;in;i++) /*输出所有的学生信息*/

{

printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,

stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);

}

printf("\n\n\n\t\t\t按任意键返回菜单");

getch();

}

void search_name() /*按姓名查看函数*/

{

system("CLS");

int i;

char name[20]; /*声明字符数组*/

printf("\t\t\t请输入学生姓名:\n");

scanf("%s",name);

printf("\t学号\t姓名\t性别\t英语\t数学\t语文\t平均成绩\t总成绩\n");

for(i=0;in;i++)

if(strcmp(stu[i].name,name)==0) /*将输入的姓名与结构体中的姓名进行比较*/

{

printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,

stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);

printf("\n\n\n\t\t\t按任意键返回菜单");

}

getch();

}

void search_number() /*定义按学号查看函数*/

{

system("CLS");

int i;

char number[15]; /*声明字符数组*/

printf("\t\t\t请输入学号:\n");

scanf("%s",number);

printf("\t学号\t姓名\t性别\t英语\t数学\t语文\t平均成绩\t总成绩\n");

for(i=0;in;i++)

if(strcmp(stu[i].num,number)==0) /*将输入的学号与结构体中的学号进行比较*/

printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,

stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);

printf("\n\n\n\t\t\t按任意键返回菜单");

getch();

}

void order() /*定义排序函数*/

{

system("CLS");

int i,j;

char a;

struct student temp; /*声明结构体变量*/

printf("\t学号\t姓名\t性别\t英语\t数学\t语文\t平均成绩\t总成绩\n");

for(i=0;in;i++) /*对数据进行排序*/

{

for(j=i+1;jn;j++)

if(stu[i].sumstu[j].sum)

{

temp=stu[i];

stu[i]= stu[j];

stu[j]=temp;

}

printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,

stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);

}

getch();

printf("是否保存?(y or n)");

getchar();

scanf("%c",a);

if(a=='y') /*是否保存排序后的文件*/

save();

else

printf("退出");

getch();

}

void del() /*定义删除学生信息函数*/

{

int i;

char a;

char name[20];

system("CLS");

printf("\t\t\t输入学生名字:\n");

scanf("%s",name);

system("CLS");

printf("\t学号\t姓名\t性别\t英语\t数学\t语文\t平均成绩\t总成绩\n");

for(i=0;in;i++)

if(strcmp(stu[i].name,name)==0)

{

printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,

stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);

getch();

printf("真的删除?(y or n)");

getchar();

scanf("%c",a);

if(a=='y') /*是否删除该信息*/

{

for(;in;i++)

stu[i]=stu[i+1];

n=n-1;

printf("你已经删除信息");

}

else

printf("退出");

getch();

}

save();

}

int openl() /*定义打开文件函数*/

{

system("CLS");

int i;

FILE *fp;

if((fp=fopen("student.txt","rb"))==NULL)

{

printf("Cannot open file.\n");

exit(0);

}

for(i=0;!feof(fp);i++)

fread(stu[i],sizeof(struct student),1,fp);

fclose(fp);

return(i-1);

}

void see() /*打开并查看文件*/

{

system("CLS");

int i;

n=openl();

printf("文件打开成功!\n");

printf("按任意键查看!\n");

getch();

printf("\t学号\t姓名\t性别\t英语\t数学\t语文\t平均成绩\t总成绩\n");

for(i=0;in;i++) /*输出所有的学生信息*/

{

printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,

stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);

}

printf("\n\n\n\t\t\t按任意键返回菜单");

getch();

求教C语言!我可以通过记事本查看到Phone Number文件中的内容,但总是无法实现Look()函数功能,显示查无此人.

int All;

注意一下,All是全局变量,如果程序结束了,All的数值将消失。重新运行程序,直接进行浏览操作,这时候All=0,所以 for(numL=1;numL=All;numL++)根本不进行。

可以把All单独写进一个文件保存,程序运行时先读取它。或者

while(fread(pL,sizeof(struct Phone),1,pLf)==EOF)判断文件读取到末尾,把文件东西先提前读出,在判断输入的名字是否匹配。

C语言问题

这是一个for语句,根据for语句的形式:for(语句1;语句2;语句3){函数体;}

的执行顺序是:语句1,判断语句2是否成立(非0为真,0为假)函数体,最后是语句3,(£)再进行判断语句2,是否成立,在执行函数体,语句3

,在执行(£)知道条件不满足语句2,跳出循环;如果,语句2是非逻辑表达式,即非判断语句时,循环体内,必有满足条件的跳出语句

break,否则为死循环;

这里的

for(k=1;k+1;k++)

可以这样解释:执行循环for()语句时,初始条件

K=1;之后执行

K+1

(k=2,非0,条件为真继续执行)之后执行函数体for下面花括号{}的内容,之后在执行

K++(K自增1)

所以,明白for()语句的执行顺序就可以明白了,明白了吗?


文章题目:c语言的look函数 c语言中lookup函数功能
本文链接:http://bjjierui.cn/article/hhhshh.html

其他资讯