C语言版幸运数字课程设计
程序设计实践(报告)
题目:
二级学院 _ __ 专 业 班 级 _ _ 姓 名
__ _ 学 号
指导教师 _____
年 月 日
issued on behalf on the basis of quality, speed up the compilation progress, is now called Pingliang information complete draft writing tasks and lower local extension of the data collection. Jingning
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<stdlib.h>
#define LEN sizeof(struct NODE)
//结构体
struct NODE
{
int no;
char name [13];
int luck_no;
char date [10];
struct NODE *next;
};
//全局变量
int n,t,xgh;
FILE *fp;
struct NODE *head,*p1,*p2; struct NODE *p;
char c;
char dym[13];
//读取文件
struct NODE *creat (void ) {
n=0;
if
((fp=fopen("","r"))==NULL)
{
printf("can not open\n");
exit(0);
}
p1=p2=(struct NODE *) malloc (LEN);
fscanf(fp,"%d %s %d
%s",&p1->no,&p1->name,&p1->luck_no,&p1->date );
head=NULL;
while(!feof(fp))
{
1
n=n+1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct NODE*)malloc(LEN); fscanf(fp,"%d %s %d %s",&p1->no,&p1->name,&p1->luck_no,&p1->date );
}
p2->next=NULL;
fclose(fp);
return(head);
}
//输出表函数
void print (struct NODE *head) {
p=head;
if(head!=NULL)
do
{
printf("%d %s %d %s\n",p->no,p->name,p->luck_no,p->date);
p=p->next;
}while(p!=NULL);
c++课程设计报告}
//分析函数
void analyse (struct NODE *head) {
int t;
p=head;
printf("\n幸运数字与出生日相同的人如下:\n"); while(p!=NULL)
{
t=(int)(p->date[8]-48)*10+(int)(p->date[9]-48);
if(t==p->luck_no)
printf("%d %s %d %s\n",p->no,p->name,p->luck_no,p->date);
p=p->next;
}
system("pause");}
ing tasks and lower local extension of the data collection. Jingningon behalf on the basis of quality, speed up the compilation progress, is now called Pingliang information complete draft writ issued2
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论