c语言作业. 旅游景点管理程序(大一的作业) 主要用结构体数组实现,用结构体表示每项记录,包含数据

Python044

c语言作业. 旅游景点管理程序(大一的作业) 主要用结构体数组实现,用结构体表示每项记录,包含数据,第1张

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

/*------------数据区--------*/

int SIZE=2

struct Spot{

char id[10] //景点编号

char name[20]//景点名称

char address[50] //景点地址

float cost //费用

}

struct Spot scenery[20]

char sub_id[10] //用于储存要查询、修改、删除景点的编号

/*-----------函数声明区--------*/

void Input(Spot scenery[],int SIZE) //录入函数

void Del(Spot scenery[],char sub_id[],int &SIZE) //删除函数

void Alter(Spot scenery[],char sub_id[],int SIZE)//修改函数

void Output(Spot scenery[],int SIZE) //显示函数

void Select(Spot scenery[],char sub_id[],int SIZE) //查询函数

void Count(Spot scenery[],int SIZE) //统计函数

void Exit() //退出函数

/*------------函数定义区-----------*/

void Input(Spot scenery[10],int SIZE)

{

int i

printf("please input\n")

printf("------------------------------------------\n")

for(i=0i<SIZEi++)

{

printf("please input id:")

gets(scenery[i].id)

printf("please input name:")

gets(scenery[i].name)

printf("please input address:")

gets(scenery[i].address)

printf("please input cost:")

scanf("%f",&scenery[i].cost)

fflush(stdin) //清空键盘缓冲区

printf("\n")

}

printf("------------------输入完毕----------------\n")

}

void Del(Spot scenery[],char sub_id[],int &SIZE)

{

int i,j

printf("please input delete spot's id:")

gets(sub_id)

for(i=0i<SIZEi++)

{

if(strcmp(scenery[i].id,sub_id)==0)

{

for(j=ij<SIZEj++)

scenery[j]=scenery[j+1]

SIZE--

}

}

printf("-------------删除成功-------------\n")

}

void Alter(Spot scenery[],char sub_id[],int SIZE)

{

int i

printf("please input alter spot's id:")

gets(sub_id)

for(i=0i<SIZEi++)

{

if(strcmp(scenery[i].id,sub_id)==0)

{

printf("alter spot's name is:")

gets(scenery[i].name)

printf("alter spot's address is:")

gets(scenery[i].address)

printf("alter spot's cost is:")

scanf("%f",&scenery[i].cost)

fflush(stdin)

break

}

}

printf("-------------修改成功------------\n")

}

void Output(Spot scenery[],int SIZE)

{

int i

printf("output scenery:\n")

printf("----------------------------------------\n")

for(i=0i<SIZEi++)

{

printf("id:%s name:%s address:%s cost:%.2f\n",scenery[i].id,scenery[i].name,scenery[i].address,scenery[i].cost)

}

printf("------------------输出完毕---------------\n")

}

void Select(Spot scenery[],char sub_id[],int SIZE)

{

int i

printf("please input select spot's id:")

gets(sub_id)

printf("-----------------查询结果--------------\n")

for(i=0i<SIZEi++)

{

if(strcmp(scenery[i].id,sub_id)==0)

printf("id:%s name:%s address:%s cost:%.2f\n",scenery[i].id,scenery[i].name,scenery[i].address,scenery[i].cost)

}

}

void Count(Spot scenery[],int SIZE)

{

int i

float sum //sum用于储存总费用

printf("-------------------统计结果------------\n")

for(i=0,sum=0i<SIZEi++)

sum+=scenery[i].cost

printf("scenery number is:%d cost is:%.2f\n",SIZE,sum)

}

void Exit()

{

printf("----------------已退出--------------\n")

exit(1)

}

/*-------------主函数----------*/

void main()

{

int s

while(1)

{

printf("please input:\n")

printf("1、录入。\n2、删除。\n3、修改。\n4、显示。\n5、查询。\n6、统计。\n7、退出。\n")

scanf("%d",&s)

fflush(stdin)

switch(s)

{

case 1:Input(scenery,SIZE)break

case 2:Del(scenery,sub_id,SIZE)break

case 3:Alter(scenery,sub_id,SIZE)break

case 4:Output(scenery,SIZE)break

case 5:Select(scenery,sub_id,SIZE)break

case 6:Count(scenery,SIZE)break

case 7:Exit()break

default:printf("please input again:")break

}

}

}

#include<graphics.h>

#include<stdio.h>

#include<stdlib.h>

#include<alloc.h>

#include<math.h>

main()

{

void *ptr

int gd=DETECT

int gm

float i

initgraph(&gd,&gm,"d:\\tc")

setactivepage(1)

setcolor(RED)

setfillstyle(1,14)

fillellipse(10,10,10,10)

ptr=malloc(imagesize(0,0,20,20))

getimage(0,0,20,20,ptr)

randomize()

setactivepage(0)

for (i=0i<3000i++)

putpixel(random(640),random(480),random(15))

for (i=0i<6.28*4i=i+0.005)

{

putimage(300+8*(cos(i)+i*sin(i)),240+6*(sin(i)-i*cos(i)),ptr,COPY_PUT)

putimage(300+8*(cos(i)+i*sin(i)),240+6*(sin(i)-i*cos(i)),ptr,COPY_PUT)

if (kbhit())

break

delay(10)

}

getch()

closegraph()

}

vc++6.0测试通过

#include <stdio.h>

#include <string.h>

#include<stdlib.h>

#define M 60

#define PAGE 5

#define replace "%9ld,%-10s,%11l,%-15s,-5%d,%-11l,%s\n"

int sum=0

struct student/*建立通迅录*/

{

long num[9]/*学号*/

char name[8]/*姓名*/

long phonenum[11]/*联系方式*/

char addr[20]/*家庭住址*/

int donum[5]/*宿舍号*/

long qq[10]/*QQ号码*/

char email[20]/*电子邮箱*/

}

struct student student[M],b[M]

void clrscr()

{ getchar()

system("cls")

}

save(int sum)

{ FILE *fp

int i

if((fp=fopen("tong_xun_lu.txt","wb"))==NULL)

}