本篇文章给大家谈谈简单的c语言系统设计,以及简单的c语言系统设计教程对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、c语言课程设计:图书管理系统设计的基本思路是什么?2、用C语言编写“销售管理系统设计”程序3、c语言简单程序设计的步骤和过程?4、c语言 学生管理系统设计
c语言课程设计:图书管理系统设计的基本思路是什么?
图书管理系统主要要求可以录入书籍,添加书目,查找书本信息,删除或修改信息,有的还要求显示是否被借阅等。
一般采用结构体数组,链表,文件操作和自定义函数。主要是需要对基础知识掌握牢固。
先定义结构体,然后对结构体的成员进行定义,选择数组存储书本各种信息。录入信息可以用for和do while循环等来做。
存放信息需要文件操作函数,比如fopen,fwrite等。
删除和添加可以删除节点或者增加节点。
查找之类的可以用字符串操作的各种函数实现。
附上参考源代码
#include stdio.h
#include string.h
#include stdlib.h
#include conio.h
#define books “f:\\books.txt”
#define booksbak “f:\\booksbak.txt”
struct bookinfo
{
char isbn[20];
char title[30];
char author[20];
int count;
};
struct book
{
struct bookinfo onebook;
struct book *next;
};
struct book *searchBook ( struct book *listptr,char isbn[])
{
while(listptr!=(struct book *)0)
if (strcmp(listptr-onebook.isbn,isbn)==0)
return listptr;
else
listptr=listptr-next;
return (struct book *)0;
}
void MainSearchbook(struct book *firstptr)
{
struct book *ptr;
char isbnno[20];
printf(“请输入ISBN:”);
scanf(“%s”,isbnno);
ptr=searchBook(firstptr,isbnno);
if (ptr!=(struct book *)0)
{
printf(“找到了!!!\n”);
printf(“ISBN:%s\n”,ptr-onebook.isbn);
printf(“Title:%s\n”,ptr-onebook.title);
printf(“Author:%s\n”,ptr-onebook.author);
}
else
printf(“sorry,not found!!!\n”);
}
int addBook(struct book *listptr,struct bookinfo note)
{
while(listptr-next!=0)
listptr=listptr-next;
listptr-next=(struct book *)malloc(sizeof(struct book));
listptr-next-onebook=note;
listptr-next-next=0;
return 0;
}
void MainAdd(struct book *listptr,FILE *fp)
{
int ok;
struct bookinfo note;
printf(“请输入ISBN:”);
scanf(“%s”,¬e.isbn);
printf(“请输入Title:”);
scanf(“%s”,¬e.title);
printf(“请输入Author:”);
scanf(“%s”,¬e.author);
ok=addBook(listptr,note);
if (ok==0)
{
//将加入的图书写到文件中保存
fprintf(fp,”\n%s %s %s %d”,note.isbn,note.title,note.author,0);
printf(“添加图书成功!!!\n”);
}
else
printf(“添加图书失败!!!\n”);
}
int removeBook(struct book *listptr,char isbn[])
{
while(listptr-next!=(struct book *)0)
{
if (strcmp(listptr-next-onebook.isbn,isbn)==0)
{
listptr-next=listptr-next-next;
return 0;
}
else
listptr=listptr-next;
}
return -1;
}
void MainRemove(struct book *listptr,FILE *fp)
/************************************************************************/
/* 删除书籍函数,通过ISBN删除链表节点,同时删除文件中对应信息 */
/* 删除文件中一行,用的是笨方法,把需要的信息写到新文件,删除旧文件,重命名..*/
/************************************************************************/
{
char isbnno[20];
int ok;
struct bookinfo onebook;
printf(“请输入ISBN:”);
scanf(“%s”,isbnno);
ok=removeBook(listptr,isbnno);
if (!ok)
{
FILE *fpbak;
if ((fpbak=fopen(booksbak,”a+”))==NULL)
printf(“文件打开失败!!!\n”);
fseek(fp,0,SEEK_SET); //移到文件开始
while((fscanf(fp,”%s %s %s %d\n”,onebook.isbn,onebook.title,onebook.author,onebook.count))!=EOF)
{
if (strcmp(onebook.isbn,isbnno)!=0)
{
fprintf(fpbak,”%s %s %s %d\n”,onebook.isbn,onebook.title,onebook.author,onebook.count);
}
}
fclose(fp);
fclose(fpbak);
if (remove(books)) //删除失败返回非0
{
printf(“删除文件失败!!!\n”);
return ;
}
else
if (rename(booksbak,books)) //重命名失败返回非0值
{
printf(“重命名失败!!!\n”);
return ;
}
printf(“删除成功!!!\n”);
}
else
printf(“查无此书!!!”);
}
int choice(void)
{
int c;
printf(“1.查看图书\n”);
printf(“2.添加图书\n”);
printf(“3.删除图书\n”);
printf(“4.退出程序\n”);
printf(“请选择序号:”);
return c=getchar();
//return c=getche();
printf(“\n\n”);
}
int addEntry(FILE *fp,struct book *firstptr)
/************************************************************************/
/* 主要用来加载文件中存放的图书信息 */
/************************************************************************/
{
struct bookinfo onebook;
while((fscanf(fp,”%s %s %s %d\n”,onebook.isbn,onebook.title,onebook.author,onebook.count))!=EOF)
{
while(firstptr-next!=0)
firstptr=firstptr-next;
firstptr-next=(struct book *)malloc(sizeof(struct book));
firstptr-next-onebook=onebook;
firstptr-next-next=0;
}
return 0;
}
int main(int argc,char *argv[])
{
int ch;
struct book first;
strcpy(first.onebook.isbn,”123456″);
strcpy(first.onebook.title,”Programming C”);
strcpy(first.onebook.author,”yhb”);
first.next=0;
struct book *firstptr=first; //链表头指针
FILE *fp;
if ((fp=fopen(books,”a+”))==NULL)
printf(“文件打开失败!!!”);
addEntry(fp,firstptr);
while(1)
{
system(“CLS”); //清屏
/************************************************************************/
/* 想想这里为什么要清空缓冲区? */
/*由于上一次(choice函数)的getchar(),还有一个’\n’留在缓冲区…. */
/*可以把这句话注释掉看看,没有这句话会遇到麻烦 */
/*如果不用fflush,可以将上面的getchar()换成getche() */
/*比较getchar(),getch(),getche()…… */
/************************************************************************/
fflush(stdin);
ch=choice()-48;
switch (ch)
{
case 1:
MainSearchbook(firstptr);
break;
case 2:
MainAdd(firstptr,fp);
break;
case 3:
MainRemove(firstptr,fp);
break;
case 4:
printf(“谢谢使用…\n”);
exit(0);
default:
printf(“请输入正确序号!”);
}
system(“PAUSE”);
}
return 0;
}
用C语言编写“销售管理系统设计”程序
讲下设计思想吧
便条实际上包含了登陆信息了,所以省去了登陆环节,简单点做到如下几点就可以 了:
1、调用c的图形类创建一菜单,有便条录入、和信息查询两栏,信息查询下面再分各种查询
2、便条录入可以都不用图形界面了,直接按条目输入值,顺序输入即可
3、保存以文件形式,可以在第一次建立个txt文档,以制表符分割开来各个字段,但是每次写入的时候必须按行作为一条数据,可以适当增加需要的字段作为查询统计方便用(每个制表符分割的为一个字段)。
4、查询统计就直接检索这个txt文档,该加总的求平均的用循环去查即可。
5、结果输出即把查到的内容在屏幕上打印出来即可。
其他,如果用c++做就简单多了,没那么多代码写
c语言简单程序设计的步骤和过程?
c程序设计方法包括三个基本步骤:
第一步二分析问题.
第二步画出程序的基本轮廓.
第三步:实现该程序.(1)编写程序;(2)测试和调试程序;(3)提供数据打印结果.
c语言 学生管理系统设计
#include stdio.h
#include string.h
#include stdlib.h
#define MAX 1000
/*定义学生成绩信息结构*/
struct stu
{
char id[8];
char name[8];
double Chinese;
double Math;
double English;
double average;
double total;
};
/*学生结构数组,用于存储学生成绩信息*/
struct stu students[MAX];
/*当前学生人数*/
int current;
void input()
{
int i;
printf(“请输入学生人数:”);
scanf(“%d”, current);
for (i = 0; i current; i++)
{
printf(“\n请输入学生学号,最多为7位数: “);
scanf(“%s”, students[i].id);
printf(“请输入学生姓名:”);
scanf(“%s”, students[i].name);
printf(“请输入语文成绩:”);
scanf(“%lf”, students[i].Chinese);
printf(“请输入数学成绩:”);
scanf(“%lf”, students[i].Math);
printf(“请输入英语成绩:”);
scanf(“%lf”, students[i].English);
students[i].total = students[i].Chinese + students[i].Math + students[i].English;
students[i].average = students[i].total / 3;
}
}
/*排名次,即对学生结构数组排序*/
void sort(struct stu array[], int n)
{
int i, j;
struct stu temp;
for (i = 0; i n; i++)
{
for (j = i+1; j n; j++)
{
if (array[i].average – array[j].average 1e-16)
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}
/*统计平均成绩,并输出各分数段的人数*/
void print_score(struct stu array[], int n)
{
int i;
double ave = 0;
int sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
for (i = 0; i n; i++)
{
ave += array[i].average;
switch ((int)(array[i].average / 10))
{
case 10:
case 9: sum1++; break;
case 8: sum2++; break;
case 7:
case 6: sum3++; break;
default: sum4++;
}
}
printf(“全班的平均分为:%.1f\n”, ave/n);
printf(“平均分在90分以上的人数为:%d\n”, sum1);
printf(“平均分在80~89的人数为:%d\n”, sum2);
printf(“平均分在60~79的人数为:%d\n”, sum3);
printf(“平均分在60分以下的人数为:%d\n”, sum4);
}
/*输出不及格科目及学生名单*/
void print_unreach(struct stu array[], int n)
{
int i;
printf(“科目\t学号\t名字\n”);
for (i = 0; i n; i++)
{
if (array[i].Chinese 60)
{
printf(“语文\t%s\t%s\n”, array[i].id, array[i].name);
}
if (array[i].Math 60)
{
printf(“数学\t%s\t%s\n”, array[i].id, array[i].name);
}
if (array[i].English 60)
{
printf(“英语\t%s\t%s\n”, array[i].id, array[i].name);
}
}
}
/*打印优等生名单*/
void print_good(struct stu array[], int n)
{
int i;
char mark = 0;
if (n 3)
{
n = 3;
}
printf(“学号\t姓名\t语文\t数学\t英语\t平均分\t名次\n”);
for (i = 0; i n; i++)
{
if ((array[i].Chinese 60) (array[i].Math 60) (array[i].English 60))
{
if (array[i].average 90) mark = 1;
else if (array[i].average 85)
{
if (array[i].Chinese == 100) mark = 1;
if (array[i].Math == 100) mark = 1;
if (array[i].English == 100) mark = 1;
if (array[i].Chinese 95 array[i].English 95) mark = 1;
if (array[i].Chinese 95 array[i].Math 95) mark = 1;
if (array[i].Math 95 array[i].English 95) mark = 1;
}
if (mark == 1)
{
printf(“%s\t%s\t”, array[i].id, array[i].name);
printf(“%.f\t%.f\t%.f\t%.1f\t”, array[i].Chinese, array[i].Math, array[i].English, array[i].average);
printf(“%d\n”, i+1);
}
}
}
}
/*按学生姓名查询成绩*/
void search_name(struct stu array[], int n, char* name)
{
int i;
char mark = 1;
for (i = 0; i n; i++)
{
if (strcmp(name, array[i].name) == 0)
{
printf(“学生姓名:%s\n”, name);
printf(“学生学号:%s\n”, array[i].id);
printf(“语文:%.f\n”, array[i].Chinese);
printf(“数学:%.f\n”, array[i].Math);
printf(“英语:%.f\n”, array[i].English);
printf(“平均分:%.1f\n”, array[i].average);
mark = 0;
}
}
if (mark == 1) puts(“不存在该学生记录”);
}
/*按学生学号查询成绩*/
void search_id(struct stu array[], int n, char* id)
{
int i;
char mark = 1;
for (i = 0; i n; i++)
{
if (strcmp(id, array[i].id) == 0)
{
printf(“学生姓名:%s\n”, array[i].name);
printf(“学生学号:%s\n”, array[i].id);
printf(“语文:%.f\n”, array[i].Chinese);
printf(“数学:%.f\n”, array[i].Math);
printf(“英语:%.f\n”, array[i].English);
printf(“平均分:%.1f\n”, array[i].average);
mark = 0;
break;
}
}
if (mark == 1) puts(“不存在该学生记录”);
}
void print_menu()
{
system(“cls”);
printf(“1.输入学生信息\n”);
puts(“2.统计全班学生成绩”);
puts(“3.按学号查询学生成绩”);
puts(“4.按姓名查询学生成绩”);
puts(“5.输出不及格情况”);
puts(“6.输出优等生名单”);
puts(“0.退出本程序”);
printf(“\n\n 请输入你的选择:”);
}
int main(int argc, char **argv)
{
char ch = 0;
char id[8], name[8];
while (ch != ‘0’)
{
print_menu();
ch = getchar();
switch (ch)
{
case ‘1’:
{
system(“cls”);
input();
sort(students, current);
break;
}
case ‘2’:
{
system(“cls”);
print_score(students, current);
break;
}
case ‘3’:
{
system(“cls”);
printf(“请输入学号:”);
scanf(“%s”, id);
search_id(students, current, id);
break;
}
case ‘4’:
{
system(“cls”);
printf(“请输入姓名:”);
scanf(“%s”, name);
search_name(students, current, name);
break;
}
case ‘5’:
{
system(“cls”);
print_unreach(students, current);
break;
}
case ‘6’:
{
system(“cls”);
print_good(students, current);
break;
}
case ‘0’: exit(0);
}
printf(“\n\n按任意键返回主菜单……”);
getchar();
getchar();
}
return 0;
}
关于简单的c语言系统设计和简单的c语言系统设计教程的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。