输入一个雇员的户户通工号申请 姓名 成绩 学号 用户指针输出一个雇员的姓名 成绩 学

上机考试题库10级[1]_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
187页免费33页免费8页免费8页免费72页免费 18页免费90页2下载券13页免费13页免费7页免费
喜欢此文档的还喜欢11页免费13页免费171页免费7页免费2页免费
上机考试题库10级[1]|计​算​机​知​识
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢求java用c语言写一个的一个关于学生的名字,学号,成绩等一些的全英文编程
求java用c语言写一个的一个关于学生的名字,学号,成绩等一些的全英文编程
/*学生成绩管理程序编制一个统计学生考试分数的管理程序。设学生成绩已以一个学生一个记录的形式存储在文件中,每位学生记录包含的信息有:姓名,学号和各门功课的成绩。程序具有以下几项功能:求出各门课程的总分,平均分,按姓名,按学号寻找其记录并显示,浏览全部学生成绩和按总分由高到低显示学生信息等。*/#include &stdio.h&#define SWN
3 /* 课程数 */#define NAMELEN
20 /* 姓名最大字符数 */#define CODELEN
10 /* 学号最大字符数 */#define FNAMELEN 80 /* 文件名最大字符数 */#define BUFLEN
80 /* 缓冲区最大字符数 *//* 课程名称表 */char schoolwork[SWN][NAMELEN+1] = {"Chinese","Mathematic","English"};struct record{ char name[NAMELEN+1]; /* 姓名 */ char
code[CODELEN+1]; /* 学号 */ int
marks[SWN];
/* 各课程成绩 */
/* 总分 */}struct node{ char name[NAMELEN+1]; /* 姓名 */ char
code[CODELEN+1]; /* 学号 */ int
marks[SWN];
/* 各课程成绩 */ int
/* 总分 */ struct node *
/* 后续表元指针 */}* /* 链表首指针 */int total[SWN];
/* 各课程总分 */FILE *
/* 文件指针 */char stuf[FNAMELEN]; /* 文件名 *//* 从指定文件读入一个记录 */int readrecord(FILE *fpt,struct record *rpt){ char buf[BUFLEN];
if(fscanf(fpt,"%s",buf)!=1)
return 0; /* 文件结束 */ strncpy(rpt-&name,buf,NAMELEN); fscanf(fpt,"%s",buf); strncpy(rpt-&code,buf,CODELEN); for(i=0;i&SWN;i++)
fscanf(fpt,"%d",&rpt-&marks[i]); for(rpt-&total=0,i=0;i&SWN;i++)
rpt-&total+=rpt-&marks[i]; return 1;}/* 对指定文件写入一个记录 */writerecord(FILE *fpt,struct record *rpt){
fprintf(fpt,"%s\n",rpt-&name); fprintf(fpt,"%s\n",rpt-&code); for(i=0;i&SWN;i++)
fprintf(fpt,"%d\n",rpt-&marks[i]); }/* 显示学生记录 */displaystu(struct record *rpt){
printf("\nName & : %s\n",rpt-&name); printf("Code & : %s\n",rpt-&code); printf("Marks &:\n"); for(i=0;i&SWN;i++)
printf(" & & & %-15s : %4d\n",schoolwork[i],rpt-&marks[i]); printf("Total &: %4d\n",rpt-&total);}/* 计算各单科总分 */int totalmark(char *fname){ FILE *
int count,i; if((fp=fopen(fname,"r"))==NULL) {
printf("Can't open file %s.\n",fname);
return 0; } for(i=0;i&SWN;i++)
total[i]=0; count=0; while(readrecord(fp,&s)!=0) {
for(i=0;i&SWN;i++)
total[i]+=s.marks[i];
count++; } fclose(fp);
/* 返回记录数 */}/* 列表显示学生信息 */void liststu(char *fname){ FILE *
if((fp=fopen(fname,"r"))==NULL) {
printf("Can't open file %s.\n",fname);
} while(readrecord(fp,&s)!=0) {
displaystu(&s);
printf("\n & & &Press ENTER to continue...\n");
while(getchar()!='\n'); } fclose(fp); }/* 构造链表 */struct node *makelist(char *fname){ FILE *
struct node *p,*u,*v,*h;
if((fp=fopen(fname,"r"))==NULL) {
printf("Can't open file %s.\n",fname);
return NULL; } h=NULL; p=(struct node *)malloc(sizeof(struct node)); while(readrecord(fp,(struct record *)p)!=0) {
while(v&&p-&total&=v-&total)
u-&next=p;
p-&next=v;
p=(struct node *)malloc(sizeof(struct node)); } free(p); fclose(fp); }/* 顺序显示链表各表元 */void displaylist(struct node *h){ while(h!=NULL) {
displaystu((struct record *)h);
printf("\n & & &Press ENTER to continue...\n");
while(getchar()!='\n');
h=h-& } }/* 按学生姓名查找学生记录 */int retrievebyn(char *fname, char *key){ FILE *
if((fp=fopen(fname,"r"))==NULL) {
printf("Can't open file %s.\n",fname);
return 0; } c=0; while(readrecord(fp,&s)!=0) {
if(strcmp(s.name,key)==0)
displaystu(&s);
} } fclose(fp); if(c==0)
printf("The student %s is not in the file %s.\n",key,fname); return 1;}/* 按学生学号查找学生记录 */int retrievebyc(char *fname, char *key){ FILE *
if((fp=fopen(fname,"r"))==NULL) {
printf("Can't open file %s.\n",fname);
return 0; } c=0; while(readrecord(fp,&s)!=0) {
if(strcmp(s.code,key)==0)
displaystu(&s);
} } fclose(fp); if(c==0)
printf("The student %s is not in the file %s.\n",key,fname); return 1;}main(){ int i,j,n;
char buf[BUFLEN]; FILE *
clrscr(); printf("Please input the students marks record file's name: "); scanf("%s",stuf); if((fp=fopen(stuf,"r"))==NULL) {
printf("The file %s doesn't exit, do you want to creat it? (Y/N) ",stuf);
getchar();
c=getchar();
if(c=='Y'||c=='y')
fp=fopen(stuf,"w");
printf("Please input the record number you want to write to the file: ");
scanf("%d",&n);
for(i=0;i&n;i++)
printf("Input the student's name: ");
scanf("%s",&s.name);
printf("Input the student's code: ");
scanf("%s",&s.code);
for(j=0;j&SWN;j++)
printf("Input the %s mark: ",schoolwork[j]);
scanf("%d",&s.marks[j]);
writerecord(fp,&s);
fclose(fp);
} } fclose(fp); getchar(); /*clrscr();*/ puts("Now you can input a command to manage the records."); puts("m : mean of the marks."); puts("t : total of the marks."); puts("n : search record by student's name."); puts("c : search record by student's code."); puts("l : list all the records."); puts("s : sort and list the records by the total."); puts("q : quit!"); while(1) {
puts("Please input command:");
scanf(" %c",&c);
/* 输入选择命令 */
if(c=='q'||c=='Q')
puts("\n Thank you for your using.");
/* q,结束程序运行 */
case 'm': /* 计算平均分 */
if((n=totalmark(stuf))==0)
puts("Error!");
printf("\n");
for(i=0;i&SWN;i++)
printf("%-15s's average is: %.2f.\n",schoolwork[i],(float)total[i]/n);
case 't': /* 计算总分 */
if((n=totalmark(stuf))==0)
puts("Error!");
printf("\n");
for(i=0;i&SWN;i++)
printf("%-15s's total mark is: %d.\n",schoolwork[i],total[i]);
case 'n': /* 按学生的姓名寻找记录 */
printf("Please input the student's name you want to search: ");
scanf("%s",buf);
retrievebyn(stuf,buf);
case 'c': /* 按学生的学号寻找记录 */
printf("Please input the student's code you want to search: ");
scanf("%s",buf);
retrievebyc(stuf,buf);
case 'l': /* 列出所有学生记录 */
liststu(stuf);
case 's': /* 按总分从高到低排列显示 */
if((head=makelist(stuf))!=NULL)
displaylist(head);
相关知识等待您来回答
编程领域专家已有天涯账号?
这里是所提的问题,您需要登录才能参与回答。
"天涯问答"是天涯社区旗下的问题分享平台。在这里您可以提问,回答感兴趣的问题,分享知识和经历,无论您在何时何地上线都可以访问,此平台完全免费,而且注册非常简单。
建立一个学生信息链表,每个结点包括:学号、姓名、成绩。
建立一个学生信息链表,每个结点包括:学号、姓名、成绩。
09-07-03 &匿名提问 发布
public class studentperson {  /// &summary&  /// 实例化一个新的学生  /// &/summary&  public studentperson(int studentid, string studentname ,string studentpoint)  {   pri_id =   pri_name =   pri_point =  }  public studentperson()  {}    private int pri_  private string pri_  private decimal pri_  /// &summary&  /// 学生学号  /// &/summary&  public int id  {   get   {    return pri_   }   set   {    pri_id =   }  }  /// &summary&  /// 学生姓名  /// &/summary&  public string name  {   get   {    return pri_   }   set   {    pri_name =   }  }  /// &summary&  /// 学生成绩  /// &/summary&  public decimal point  {   get   {    return pri_   }   set   {    pri_point =   }  } } /// &summary& /// 结点类. /// &/summary& public class listnode {  public listnode(studentperson newvalue)  {   value=  }  /// &summary&  /// 前一个  /// &/summary&  publ  /// &summary&  /// 后一个  /// &/summary&    /// &summary&  /// 值  /// &/summary&  public } /// &summary& /// 学生链表。 /// &/summary& public class studentlist {  public studentlist()  {
  //构造函数   //初始化   listcountvalue=0;   head=   tail=  }  /// &summary&  /// 头指针  /// &/summary&  p  /// &summary&  /// 尾指针  /// &/summary&  p  /// &summary&  /// 当前指针  /// &/summary&  priv  /// &summary&  /// 链表数据的个数  /// &/summary&  privat  /// &summary&  /// 尾部添加数据  /// &/summary&  public void append(studentperson datavalue )  {   listnode newnode=new listnode( datavalue);   if (isnull())      //如果头指针为空   {    head=    tail=   }   else   {    tail.next =    newnode.previous =    tail=   }   current=   //链表数据个数加一   listcountvalue+=1;  }  /// &summary&  /// 删除当前的数据  /// &/summary&  public void delete()  {  
  //若为空链表   if ( ! isnull())   {    //若删除头    if (isbof())    {     head=current.     current =     current=     head.previous =     listcountvalue-=1;        }    //若删除尾    if (iseof())    {       tail=current.     current =     current=     tail.next =     listcountvalue-=1;        }    //若删除中间数据    current.previous.next =current.    current.next.previous =current.    current=current.    listcountvalue-=1;       }  }  /// &summary&  /// 向后移动一个数据  /// &/summary&  public bool movenext()  {   if (! iseof())   {    current=current.       }   else   {       }  }  /// &summary&  /// 向前移动一个数据  /// &/summary&  public bool moveprevious()  {   if (!isbof())   {    current=current.previous  ;       }   else   {       }  }  /// &summary&  /// 移动到第一个数据  /// &/summary&  public void movefirst()  {   current=  }  /// &summary&  /// 移动到最后一个数据  /// &/summary&  public void movelast()  {   current=  }  /// &summary&  /// 判断是否为空链表  /// &/summary&  public bool isnull()  {   if (listcountvalue==0)        }  /// &summary&  /// 判断是否为到达尾部  /// &/summary&  public bool iseof()  {   if( current  ==tail )        }  /// &summary&  /// 判断是否为到达头部  /// &/summary&  public bool isbof()  {   if( current ==head)        }  /// &summary&  /// 得到当前指针的学生信息  /// &/summary&  public studentperson getcurrentvalue()  {   return current.  }  /// &summary&  /// 取得链表的数据个数  /// &/summary&  public int listcount  {   get   {    r   }  }  /// &summary&  /// 清空链表  /// &/summary&  public void clear()  {  
  movefirst();   while (!isnull())   {    //若不为空链表,从尾部删除    delete();   }  }  /// &summary&  /// 查出是否有此学生,如果有返回信息,没有返回空值  /// &/summary&  public studentperson selectstudent(string name)  {   int nowstudent = getcurrentvalue().   if(getcurrentvalue().name == name)   {    return getcurrentvalue() ;   }   else   {    while(selectname != getcurrentvalue().name)    {     if(!movenext())     {      movefirst() ;     }     if(nowstudent == getcurrentvalue().id)     {           }    }    return getcurrentvalue() ;   }  }  /// &summary&  /// 在当前位置前插入数据  /// &/summary&  public void insert(studentperson datavalue)  {   listnode newnode=new  listnode (datavalue);   if(isnull())   {  
   //为空表,则添加    append(datavalue);       }   if (isbof())   {    //为头部插入    newnode.next =    head.previous =    head=    current=    listcountvalue+=1;       }   //中间插入   newnode.next =   newnode.previous =current.   current.previous.next =   current.previous =   current=   listcountvalue+=1;  }  /// &summary&  /// 按学号升序插入  /// &/summary&  public void insertascendingbyid(studentperson insertvalue)  {   //参数:insertvalue 插入的数据   //为空链表   if (isnull())   {  
   //添加    append(insertvalue);       }   //移动到头   movefirst();   if ((&getcurrentvalue().id))   {  
   //满足条件,则插入,退出    insert(insertvalue);       }   while(true)   {  
   if (&getcurrentvalue().id)    {     //满足条件,则插入,退出     insert(insertvalue);        }    if (iseof())    {  
    //尾部添加     append(insertvalue);        }    //移动到下一个指针    movenext();   }  }  /// &summary&  /// 按学号降序插入  /// &/summary&  public void insertunascendingbyid(studentperson insertvalue)  {   //参数:insertvalue 插入的数据   //为空链表   if (isnull())   {  
   //添加    append(insertvalue);       }   //移动到头   movefirst();   if (&getcurrentvalue().id)   {  
   //满足条件,则插入,退出    insert(insertvalue);       }   while(true)   {  
   if (&getcurrentvalue().id)    {     //满族条件,则插入,退出     insert(insertvalue);        }    if (iseof())    {  
    //尾部添加     append(insertvalue);        }    //移动到下一个指针    movenext();   }  }  /// &summary&  /// 按成绩升序插入  /// &/summary&  public void insertascendingbypoint(studentperson insertvalue)  {   //参数:insertvalue 插入的数据   //为空链表   if (isnull())   {  
   //添加    append(insertvalue);       }   //移动到头   movefirst();   if ((insertvalue.point&getcurrentvalue().point))   {  
   //满足条件,则插入,退出    insert(insertvalue);       }   while(true)   {  
   if (insertvalue.point&getcurrentvalue().point)    {     //满足条件,则插入,退出     insert(insertvalue);        }    if (iseof())    {  
    //尾部添加     append(insertvalue);        }    //移动到下一个指针    movenext();   }  }  /// &summary&  /// 按成绩降序插入  /// &/summary&  public void insertunascendingbypoint(studentperson insertvalue)  {   //参数:insertvalue 插入的数据   //为空链表   if (isnull())   {  
   //添加    append(insertvalue);       }   //移动到头   movefirst();   if (insertvalue.point&getcurrentvalue().point)   {  
   //满足条件,则插入,退出    insert(insertvalue);       }   while(true)   {  
   if (insertvalue.point&getcurrentvalue().point)    {     //满族条件,则插入,退出     insert(insertvalue);        }    if (iseof())    {  
    //尾部添加     append(insertvalue);        }    //移动到下一个指针    movenext();   }  } }
请登录后再发表评论!四川大学数据库技术复习题 三 操作题_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
2页¥5.0024页免费16页免费2页¥5.002页¥5.00 2页¥5.003页¥10.0011页免费6页免费4页免费
喜欢此文档的还喜欢4页1下载券27页1下载券9页2下载券85页2下载券11页2下载券
四川大学数据库技术复习题 三 操作题|四​川​大​学00​年​数​据​库​技​术​题​库
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢1196人阅读
第七章例73.cpp : 定义控制台应用程序的入口点。
* Copyright (c) 2012, 烟台大学计算机学院
* All rights reserved.
* 完成日期:2012 年 12 月 09 日
* 版 本 号:v1.0
* 输入描述: 定义一个结构体变量stu,成员包括学号,姓名,性别,成绩。
定义一个指针变量p指向该结构体变量stu,通过该指针变量输出各成员的值。
* 问题描述:
* 程序输出:
* 问题分析:略
* 算法设计:略
#include &stdafx.h&
#include&iostream&
#include&string&
int main()
struct student
student *p=&
stu.num=10301;
stu.name=&wang feng&;
stu.sex='f';
stu.score=89.5;
cout&&stu.num&&&
&&&stu.name&&&
&&&stu.sex&&&
&&&stu.score&&&
cout&&(*p).num&&&
&&&(*p).name&&&
&&&(*p).sex&&&
&&&(*p).score&&
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:128653次
积分:3040
积分:3040
排名:第4117名
原创:180篇
评论:18条
(10)(1)(5)(88)(75)(1)

我要回帖

更多关于 企业qq工号 的文章

 

随机推荐