C语言实习报告
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "string.h"
#define M 100
/*日期结构体类型*/
typedef struct
{int year;
int month;
int day;
}DATE;
/*学生成绩结构体类型*/
typedef struct
{float en; /*英语成绩*/
float c; /*C语言成绩*/
float ma; /*高数成绩*/
float ph; /*大物成绩*/
}SCORE;
/*学生结构体类型*//*学生结构体类型*/
typedef struct
{int num; /*学生学号*/
char name[8]; /*学生姓名*/
char sex[2]; /*学生性别*/
SCORE score; /*学生成绩*/
char tele[12]; /*联系电话*/
char add[20]; /*家庭住址*/
DATE birthday; /*出生日期*/
}STUDENT;
int read_file(STUDENT student[])
{ FILE *fp;
int i=0;
fp=fopen("student.txt","rt");
if(fp==NULL)
{ printf("\n\n **********库文件不存在!请创建文件**********\n");
return 0;
}
while(!feof(fp))
{
fread(&student[i],sizeof(STUDENT),1,fp);
if(!(student[i].num))
break;
else
i++;
}
fclose(fp);
return i;
}
void save_file(STUDENT student[],int stu)
{ FILE *fp;
int i;
fp=fopen("student.txt","wt");
if(fp==NULL)
{ printf("读文件出现错误!\n");
return;
}
for(i=0;i<stu;i++)
if(fwrite(&student[i],sizeof(STUDENT),1,fp)!=1)
printf("写文件出现错误!\n");
fclose(fp);
}
/*输入模块*/
int input(STUDENT student[],int stu)
{ int i=0;
system("cls");
printf("\n\n ◆输入学生信息(最多%d个)◆\n",M);
printf(" -------------------------------------------------------\n");
do
{ printf("\n ◇第%d位学生信息◇",i+1);
printf("\n ▲学生学号:");
scanf("%d",&student[i].num);
if(!(student[i].num)) break;
printf("\n △学生姓名:");
scanf("%s",student[i].name);
printf("\n ▲学生性别(m/w):");
scanf("%s",student[i].sex);
printf("\n △英语成绩:");
scanf("%f",&student[i].score.en);
printf("\n ▲C语言成绩:");
scanf("%f",&student[i].score.c);
printf("\n △高数成绩:");
scanf("%f",&student[i].score.ma);
printf("\n ▲大物成绩:");
scanf("%f",&student[i].score.ph);
printf("\n △联系电话:");
scanf("%s",student[i].tele);
printf("\n ▲家庭住址:");
scanf("%s",student[i].add);
printf("\n △学生生日(yyyy mm dd):");
scanf("%d%d%d",&student[i].birthday.year,&student[i].birthday.month,&student[i].birthday.day);
i++;
}while(i<M);
save_file(student,stu);
printf("\n ------★%d位学生
程序如下: Sub Form_Click() Dim number AS Integer NegativeSum=0:PostiveSum=0 For i=1 To 10 number=InputBox("Enter data: ") If number<0 Then Print...
代码 2页 3下载券 代码 暂无评价 3页 免费 代码 暂无评价 3页 1下载券 源码 暂无评价 24页 免费 源程序 暂无评价 1页 免费 qq代码 暂无评价 40页 1下载...
新代码 暂无评价 1页 免费 喜欢此文档的还喜欢 经典C源程序 41页 免费源代码 暂无评价0人阅读0次下载举报文档/*使用前请先建一个数据库放在同一...
程序源代码_计算机软件及应用_IT/计算机_专业资料。某某公司公开的某某软件的部分程序源代码某某软件公司公布的部分某某软件的程序源代码 using System.net; using Sys...
编辑本段概念研究 1. 理论上的概念 源代码是相对目标代码和可执行代码而言的。 源代码就是用 汇编语言和高级语言写出来的代码。 目标代码是指源代码经过编译程序...
代码>> (二),主程序 global dt t f df N T close all clear Eb_N0 Pe k=input('取样点数=2^k, k 取 13 左右'); if isempty(k), k=13; end...
代码如下: <HTML> <HEAD> <TITLE>电子图书之《ASP程序设计》</TITLE> </HEAD> <BODY> <H2>《ASP程序设计》</H2> <% Set bookLink=Server.CreateObject...
源代码是什么_计算机软件及应用_IT/计算机_专业资料。介绍源代码是什么,可供初学...下载论坛源码GBK UTF8 B... 2页 免费 05 源代码 暂无评价 114页 1下载券...
第五步:装修店铺 打开淘宝店铺,进入装修模式,进入大家想要编辑的区域,在复制代码前应该都知道,首先 要点击下 编辑拦里的 <> 编辑 HTML 源代码这一按键哦!!! ...
热门文档