cae课程设计源码
㈠ 课程设计,工资管理系统完整源代码
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define MONTH_NUM 5 /* 最多的月份 */
struct worker
{
int number; /* 每个工人的工号 */
char name[15]; /* 每个工人的姓名 */
int salary[MONTH_NUM]; /* 每个工人M月的工资 */
int sum; /* 每个工人的总工资 */
float average; /* 每个工人的平均工资 */
struct worker *next;
};
typedef struct worker STU;
char Menu(void);
int Ascending(int a, int b);
int Descending(int a, int b);
void IntSwap(int *pt1, int *pt2);
void CharSwap(char *pt1, char *pt2);
void FloatSwap(float *pt1, float *pt2);
STU *AppendNode(STU *head, const int m);
STU *DeleteNode(STU *head, int nodeNum);
STU *ModifyNode(STU *head, int nodeNum, const int m);
STU *SearchNode(STU *head, int nodeNum);
STU *Appendsalary(STU *head, const int m);
void Totalsalary(STU *head, const int m);
void Printsalary(STU *head, const int m);
STU *Deletesalary(STU *head, const int m);
void Modifysalary(STU *head, const int m);
void Sortsalary(STU *head, const int m, int (*compare)(int a, int b));
void Searchsalary(STU *head, const int m);
void DeleteMemory(STU *head);
main()
{
char ch;
int m;
STU *head = NULL;
printf("输入要记录的月份(m<10):");
scanf("%d", &m);
while (1)
{
ch = Menu();
switch (ch)
{
case'1':head = Appendsalary(head, m);
Totalsalary(head, m);
break;
case'2':Printsalary(head, m);
break;
case'3':head = Deletesalary(head, m);
printf("\nAfter deleted\n");
Printsalary(head, m);
break;
case'4':Modifysalary(head, m);
Totalsalary(head, m);
printf("\nAfter modified\n");
Printsalary(head, m);
break;
case'5':Searchsalary(head, m);
break;
case'6':Sortsalary(head, m, Descending);
printf("\nsorted in descending order by sum\n");
Printsalary(head, m);
break;
case'7':Sortsalary(head, m, Ascending);
printf("\nsorted in ascending order by sum\n");
Printsalary(head, m);
break;
case'0':exit(0);
DeleteMemory(head);
printf("End of program!");
break;
default:printf("Input error!");
break;
}
}
}
char Menu(void)
{
char ch;
printf("\n管理工人的工资\n");
printf(" 1.添加记录\n");
printf(" 2.列出记录\n");
printf(" 3.删除记录\n");
printf(" 4.修改记录\n");
printf(" 5.查找记录\n");
printf(" 6.降序排列\n");
printf(" 7.升序排列\n");
printf(" 0.退出\n");
printf("请输入你的选择:");
scanf(" %c", &ch); /*在%c前面加一个空格,将存于缓冲区中的回车符读入*/
return ch;
}
STU *Appendsalary(STU *head, const int m)
{
int i = 0;
char c;
do{
head = AppendNode(head, m); /*向链表末尾添加一个节点*/
printf("你想添加一个新的记录吗(Y/N)?");
scanf(" %c",&c); /*%c前面有一个空格*/
i++;
}while (c=='Y' || c=='y');
printf("%d new nodes have been apended!\n", i);
return head;
}
STU *Deletesalary(STU *head, const int m)
{
int i = 0, nodeNum;
char c;
do{
printf("请输入你想删除的记录编号:");
scanf("%d", &nodeNum);
head = DeleteNode(head, nodeNum); /*删除工号为nodeNum的工人信息*/
Printsalary(head, m); /*显示当前链表中的各节点信息*/
printf("Do you want to delete a node(Y/N)?");
scanf(" %c",&c); /*%c前面有一个空格*/
i++;
}while (c=='Y' || c=='y');
printf("%d nodes have been deleted!\n", i);
return head;
}
void Modifysalary(STU *head, const int m)
{
int i = 0, nodeNum;
char c;
do{
printf("请输入你想修改的记录编号:");
scanf("%d", &nodeNum);
head = ModifyNode(head, nodeNum, m); /*修改工号为nodeNum的节点*/
printf("Do you want to modify a node(Y/N)?");
scanf(" %c",&c); /*%c前面有一个空格*/
i++;
}while (c=='Y' || c=='y');
printf("%d nodes have been modified!\n", i);
}
void Totalsalary(STU *head, const int m)
{
STU *p = head;
int i;
while (p != NULL) /*若不是表尾,则循环*/
{
p->sum = 0;
for (i=0; i<m; i++)
{
p->sum += p->salary[i];
}
p->average = (float)p->sum / m;
p = p->next; /*让p指向下一个节点*/
}
}
void Sortsalary(STU *head, const int m, int (*compare)(int a, int b))
{
STU *pt;
int flag = 0, i;
do{
flag = 0 ;
pt = head;
/*若后一个节点的总工资比前一个节点的总工资高,则交换两个节点中的数据
注意只交换节点数据,而节点顺序不变,即节点next指针内容不进行交换*/
while (pt->next != NULL)
{
if ((*compare)(pt->next->sum, pt->sum))
{
IntSwap(&pt->number, &pt->next->number);
CharSwap(pt->name, pt->next->name);
for (i=0; i<m; i++)
{
IntSwap(&pt->salary[i], &pt->next->salary[i]);
}
IntSwap(&pt->sum, &pt->next->sum);
FloatSwap(&pt->average, &pt->next->average);
flag = 1;
}
pt = pt->next;
}
}while(flag);
}
/*交换两个整型数*/
void IntSwap(int *pt1, int *pt2)
{
int temp;
temp = *pt1;
*pt1 = *pt2;
*pt2 = temp;
}
/*交换两个实型数*/
void FloatSwap(float *pt1, float *pt2)
{
float temp;
temp = *pt1;
*pt1 = *pt2;
*pt2 = temp;
}
/*交换两个字符串*/
void CharSwap(char *pt1, char *pt2)
{
char temp[15];
strcpy(temp, pt1);
strcpy(pt1, pt2);
strcpy(pt2, temp);
}
/*决定数据是否按升序排序,a<b为真,则按升序排序*/
int Ascending(int a, int b)
{
return a < b;
}
/* 决定数据是否按降序排序,a>b为真,则按降序排序 */
int Descending(int a, int b)
{
return a > b;
}
void Searchsalary(STU *head, const int m)
{
int number, i;
STU *findNode;
printf("请输入你想查找的记录编号:");
scanf("%d", &number);
findNode = SearchNode(head, number);
if (findNode == NULL)
{
printf("Not found!\n");
}
else
{
printf("\nNo.%3d%8s", findNode->number, findNode->name);
for (i=0; i<m; i++)
{
printf("%7d", findNode->salary[i]);
}
printf("%9d%9.2f\n", findNode->sum, findNode->average);
}
}
void Printsalary(STU *head, const int m)
{
STU *p = head;
char str[100] = {'\0'}, temp[3];
int i, j = 1;
strcat(str, "Number Name ");
for (i=1; i<=m; i++)
{
strcat(str, "salary");
itoa(i,temp, 10);
strcat(str, temp);
strcat(str, " ");
}
strcat(str," sum average");
printf("%s", str); /* 打印表头 */
while (p != NULL) /*若不是表尾,则循环打印*/
{
printf("\nNo.%3d%15s", p->number, p->name);
for (i=0; i<m; i++)
{
printf("%7d", p->salary[i]);
}
printf("%9d%9.2f", p->sum, p->average);
p = p->next; /*让p指向下一个节点*/
j++;
}
printf("\n");
}
STU *AppendNode(STU *head, const int m)
{
STU *p = NULL;
STU *pr = head;
int j;
p = (STU *)malloc(sizeof(STU)); /*为新添加的节点申请内存*/
if (p == NULL) /*若申请内存失败,则打印错误信息,退出程序*/
{
printf("No enough memory to alloc");
exit(0);
}
if (head == NULL) /*若原链表为空表,则将新建节点置为首节点*/
{
head = p;
}
else /*若原链表为非空,则将新建节点添加到表尾*/
{
/*若未到表尾,则继续移动指针pr,直到pr指向表尾*/
while (pr->next != NULL)
{
pr = pr->next;
}
pr->next = p; /*将新建节点添加到链表的末尾*/
}
pr = p; /*让pr指向新建节点*/
printf("Input node data......");
printf("\nInput number:");
scanf("%d", &p->number);
printf("Input name:");
scanf("%s", p->name);
for (j=0; j<m; j++)
{
printf("Input salary%d:", j+1);
scanf("%d", p->salary+j);
}
pr->next = NULL; /*将新建节点置为表尾*/
return head; /*返回添加节点后的链表的头节点指针*/
}
STU *ModifyNode(STU *head, int nodeNum, const int m)
{
int j;
STU *newNode;
newNode = SearchNode(head, nodeNum);
if (newNode == NULL)
{
printf("Not found!\n");
}
else
{
printf("Input the new node data:\n");
printf("Input name:");
scanf("%s", newNode->name);
for (j=0; j<m; j++)
{
printf("Input salary%d:", j+1);
scanf("%d", newNode->salary+j);
}
}
return head;
}
STU *DeleteNode(STU *head, int nodeNum)
{
STU *p = head, *pr = head;
if (head == NULL) /*链表为空,没有节点,无法删除节点*/
{
printf("No Linked Table!\n");
return(head);
}
/*若没找到节点nodeNum且未到表尾,则继续找*/
while (nodeNum != p->number && p->next != NULL)
{
pr = p;
p = p->next;
}
if (nodeNum == p->number) /*若找到节点nodeNum,则删除该节点*/
{
if (p == head) /*若待删节点为首节点,则让head指向第2个节点*/
{
head = p->next;
}
else /*若待删节点非首节点,则将前一节点指针指向当前节点的下一节点*/
{
pr->next = p->next;
}
free(p); /*释放为已删除节点分配的内存*/
}
else /*没有找到待删除节点*/
{
printf("This Node has not been found!\n");
}
return head; /*返回删除节点后的链表的头节点指针*/
}
STU *SearchNode(STU *head, int nodeNum)
{
STU *p = head;
int j = 1;
while (p != NULL) /*若不是表尾,则循环*/
{
if (p->number == nodeNum) return p;
p = p->next; /*让p指向下一个节点*/
j++;
}
return NULL;
}
void DeleteMemory(STU *head)
{
STU *p = head, *pr = NULL;
while (p != NULL) /*若不是表尾,则释放节点占用的内存*/
{
pr = p; /*在pr中保存当前节点的指针*/
p = p->next; /*让p指向下一个节点*/
free(pr); /*释放pr指向的当前节点占用的内存*/
}
}
凑合着用吧,一些缺少的功能自己加上去就行了。。。
㈡ 怎样完整的加载或运行别人已经做好的课程设计源代码
vs 文件-->打开-->网站 选择目录 打开就行了
㈢ 课程设计报告 帮我搞定 要源码 C++写的 30分
这么点分,还想要源带码,你也太意想天开了吧!!你自己慢慢做吧
㈣ 求C语言课程设计源代码 急~!!
#include "stdio.h"
#define MAX 100 /*定义输入数据的最大长度*/
void countmax(int a[MAX],int N){ /*计算最值的函数*/
int minn=a[0],maxx=a[0]; /*minn表最小值,maxx表最大值*/
for(int i=0;i<=N;i++){ /*N是实际输入数组的长度*/
if(a[i]<minn) /*循环求最值*/
minn=a[i];
else
if(a[i]>maxx)
maxx=a[i];
}
printf("\n最小值:%d\n最大值:%d\n",minn,maxx);
printf("\n————————————————————————\n");
}
void found(int a[MAX],int N){ /*查找函数*/
int Flag = 1,x; /*Flag用来标记是否查找成功,0表成功,1表未成功*/
printf("请输入你要查找的数: ");
scanf("%d",&x); /*x是待查找的数*/
for(int i=0;i<=N;i++){
if(a[i]==x){
printf("所找的数在数组中的位置是第 %d 位\n",i+1);
Flag = 0;
break;
}
}
if(Flag == 1)
printf("Not Found!\n");
printf("————————————————————————\n");
}
void deletedata(int a[MAX],int N){ /*删除操作函数*/
int Flag = 1,x,pos; /*Flag用来标记是否删除成功,0表成功,1表未成功,pos用来记录删除的位置*/
printf("请输入你要删除的数: ");
scanf("%d",&x);
for(int i = 0;i <= N;i++){ /*在数组中循环查找所要删除的数*/
if(a[i]==x){
for(int j=i;j<=N;j++) /*删除位置后的数全部向前移动一位*/
a[j]=a[j+1];
Flag = 0;
N--; /*数组长度减1*/
pos = i; /*记录删除位置*/
break;
}
}
if(Flag==1)
printf("Not Found!");
else{
printf("删除成功!\n");
printf("所删除的数在数组中的位置是第 %d 位\n",pos+1);
}
printf("删除操作后的数据为:\n");
for(int j=0;j<=N;j++)
printf("%d ",a[j]);
printf("\n————————————————————————\n");
}
void sumdata(int a[MAX],int N){ /*求奇数和偶数函数*/
int SUM1=0,SUM2=0,N1=0,N2=0;
/*SUM1表示偶数之和,N1表偶数个数
**SUM2表示奇数之和,N2表奇数个数
*/
for(int i=0;i<=N;i++){
if(a[i]%2==0){
N1++;
SUM1 = SUM1 + a[i];
}
else{
N2++;
SUM2 = SUM2 + a[i];
}
}
printf("数据中的偶数个数为: %d 个,平均值为: %d\n",N1,SUM1/N1);
printf("数据中的奇数个数为: %d 个,平均值为: %d\n",N2,SUM2/N2);
printf("————————————————————————\n");
}
int main(){
int i=0,k,N,a[MAX],data;
/*k用来标记所选择的操作,data表示输入的数据,a数组用来存储输入的数据*/
printf("请输入数据:\n");
scanf("%d",&data);
while(data!=0){
a[i]=data;
scanf("%d",&data);
N=i++;
}
printf("\n您输入了%d个数据,如下所示:\n",N+1);
for(i=0;i<=N;i++)
printf("%d ",a[i]);
printf("\n————————————————————————");
printf("\n\n请选择下面的一个项目:\n");
printf("1、求最值\n2、查找\n3、删除\n4、统计及平均\n5、退出\n");
printf("————————————————————————\n");
scanf("%d",&k);
switch(k){
case 1:
countmax(a,N);
break;
case 2:
found(a,N);
break;
case 3:
deletedata(a,N);
break;
case 4:
sumdata(a,N);
break;
case 5:
break;
default:
break;
}
return 0;
}
㈤ 长江大学 cad cae课程设计 序号11- 豆丁网
jgbkjvbnmbjhcvjh
㈥ 求c++课程设计的源代码
题目本身不难;题目的陈述,这个文本本身难以卒读!
很难想象文本出自,华南理工大学教师之手;抄袭+生吞活剥的英翻中??
㈦ c++课程设计源代码
c++课程设计 学生管理系统源代码
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef struct stu
{
char name[20];
long int number;
int snum;
char sex[20];
char add[30] ;
char time[20];
char tel[20];
struct stu *next;
}stu,*student;
int init(student &s);
void insert(student &s);
void print(student &s);
int delete(student &s);
void find (student &s);
void findname(student &s);
void findnum(student &s);
void modifay(student &s);
void putfile(student &s);
void getfile(student &s);
void main()
{
student s;
init(s);
cout<<"欢迎使用学生管理系统."<<endl;
cout<<" "<<endl;
cout<<endl;
while(1)
{
int i;
mainint:
cout<<"请选择相关操作:"<<endl<<"1.建立学生资料文件."<<endl<<"2.浏览."<<endl<<"3.删除."<<endl;
cout<<"4.查询."<<endl<<"5.修改."<<endl<<"6.打开学生文件."<<endl<<"7.退出管理系统." <<endl<<"请选择:";
cin>>i;
if(i<0||i>7)
{
cout<<"输入了错误的数字,Again!"<<endl<<endl;
goto mainint;
}
switch(i)
{
case 1: insert(s);break;
case 2: print(s);
putfile(s);
break;
case 3: ldelete(s);break;
case 4: find(s);break;
case 5: modifay(s);
break;
case 6: getfile(s);break;
case 7: exit(0);
}
}
}
int init(student &s)
{
s=(student)malloc(sizeof(stu));
if (s)
{
s->next=NULL;
return 0;
}
else return -1;
}
void insert(student &s) //insert
{
cout<<endl;
student p,q;
p=(student)malloc(sizeof(stu));
cout<<"请输入学生信息:"<<endl;
cout<<"姓名:";
cin>>p->name;
cout<<endl;
cout<<"学号:";
cin>>p->number;
cout<<endl;
cout<<"性别:";
cin>>p->sex;
cout<<endl;
cout<<"家庭住址:" ;
cin>>p->add;
cout<<endl;
cout<<"出生年月:" ;
cin>>p->time;
cout<<endl;
cout<<"宿舍号:";
cin>>p->snum;
cout<<endl;
cout<<"宿舍号码:";
cin>>p->tel;
q=s;
while(!(q->next==NULL)&&(q->next->number<p->number))
q=q->next;
p->next=q->next;
q->next=p;
//if()p->next=NULL;
//free(p);
}
int ldelete(student &s) //delete
{
cout<<endl;
student p,a;
p=s ;
cout<<"请输入删除的学号:";
long int number;
cin>>number;
while(p)
{ if (p->number==number)
{
a->next=p->next;
free(p); return(0);}
else
{ a=p;
p=p->next;} }
cout<<"没有找到你要删除的选项!"<<endl<<endl;return(-1);
}
void print(student &s)
{
int a;
a=0;
student p;
p=s->next;
cout<<"姓名 "<<"学号 " <<"性别 "<<"家庭住址 "<<"出生年月 "<<"宿舍号"<<"宿舍号码"<<endl;
while(p)
{
a++;
cout<<p->name<<" "<<p->number<<" "<<p->sex<<" "<<p->add<<" "<<p->time<<" "<<p->snum<<" "<<p->tel<<" "<<endl;
p=p->next;
}
cout<<endl;
if (a==0)
cout<<"还没有学生信息!"<<endl<<endl ;
}
void find (student &s) //find
{
findl:
cout<<"请选择查找方法:"<<endl<<"1.按姓名查找."<<endl<<"2.按学号查找."<<endl;
cout<<"请选择:";
int k;
cin>>k;
if(k<0||k>3)
{
cout<<"输了入错误数字,Again!"<<endl<<endl;
goto findl;
}
switch(k)
{
case 1: findname(s);break;
case 2: findnum(s);break;
}
}
void findname(student &s) //find by name
{
student p;
p=s->next;
cout<<"请输入姓名:";
char name[20];
int j;
j=0;
cin>>name;
cout<<"你要查找的资料是:"<<endl;
cout<<"姓名 "<<"学号 " <<"性别 "<<"家庭住址 "<<"出生日期 "<<"宿舍号 "<<"宿舍号码"<<endl;
while(p)
{
if (strcmp(p->name,name)==0)
{
cout<<p->name<<" "<<p->number<<" "<<p->sex<<" "<<p->add<<" "<<p->time<<" "<<p->snum<<" "<<p->tel<<" "<<endl;
j++;
}
p=p->next;
}
cout<<endl;
if(j==0)
cout<<"对不起,没找到你要的信息!"<<endl<<endl ;
}
void findnum(student &s) //find by number
{
student p;
p=s->next;
cout<<"请输入学号:";
long int number;
int j;
j=0;
cin>>number;
cout<<"你要查找的资料是:"<<endl;
cout<<"姓名 "<<"学号 "<<"性别 "<<"家庭住址 "<<"出生日期 "<<"宿舍号 "<<"宿舍电话"<<endl;
while(p)
{
if (p->number==number)
{
cout<<p->name<<" "<<p->number<<" "<<p->sex<<" "<<p->add<<" "<<p->time<<" "<<p->snum<<" "<<p->tel<<" "<<endl;
j++;
}
p=p->next;
}
cout<<endl;
if(j==0)
cout<<"对不起,没找到你要的信息"<<endl<<endl ;
}
void modifay(student &s) //modifay
{
student q,p,l,m;
int j;
j=0;
q=s->next;
l=s;
m=s;
cout<<"请输入要修改的学号:" ;
long int num;
cin>>num;
cout<<"姓名 "<<"学号 "<<"性别 "<<"家庭住址 "<<"入学时间 "<<"宿舍号 "<<"电话号码"<<endl;
while(q)
{
if (q->number==num)
{
cout<<"你要修改的信息是:"<<endl;
cout<<q->name<<" "<<q->number<<" "<<q->sex<<" "<<q->add<<" "<<q->time<<" "<<q->snum<<" "<<q->tel<<" "<<endl;
j++;
p=(student)malloc(sizeof(stu));
cout<<"请输入新的学生信息:"<<endl;
cout<<"姓名:";
cin>>p->name;
cout<<endl;
cout<<"学号:";
cin>>p->number;
cout<<endl;
cout<<"年龄:";
cin>>p->age;
cout<<endl;
cout<<"性别:";
cin>>p->sex;
cout<<endl;
cout<<"家庭住址:" ;
cin>>p->add;
cout<<endl;
cout<<"入学时间:" ;
cin>>p->time;
cout<<endl;
cout<<"电话号码:";
cin>>p->tel;
l->next=q->next;
free(q);
goto tt;
}
else
{
l=q;
q=q->next;
}
}
cout<<endl;
if (j==0) cout<<"没找到你要的数据!"<<endl<<endl ;
tt:
while(!(m->next==NULL)&&(m->next->number<p->number))
m=m->next;
p->next=m->next;
m->next=p;
}
void putfile(student &s)
{
student p;
p=s->next;
FILE *fp;
if((fp=fopen("information.txt","w"))==NULL)
{
cout<<"打不开文件"<<endl<<endl;
exit(0);
}
while(p)
{
if(fwrite(p,sizeof(struct stu),1,fp)!=1 )
{
cout<<"文件写入错误"<<endl<<endl;
return;
}
p=p->next;
}
fclose(fp) ;
}
void getfile(student &s)
{
student p,q;
q=s;
FILE *fp1 ;
if((fp1=fopen("information.txt","r"))==NULL)
{
cout<<"打不开文件"<<endl;
exit(0);
}
cout<<"姓名 "<<"学号 "<<"性别 "<<"家庭住址 "<<"入学时间 "<<"宿舍号 "<<"电话号码"<<endl;
p=(student)malloc(sizeof(stu));
while(fread(p,sizeof(struct stu),1,fp1)!=0)
{
cout<<p->name<<" "<<p->number<<" "<<p->sex<<" "<<p->add<<" "<<p->time<<" "<<p->age<<" "<<p->tel<<endl;
while(!(q->next==NULL)&&(q->next->number<p->number))
q=q->next;
p->next=q->next;
q->next=p;
p=(student)malloc(sizeof(stu));
}
fclose(fp1);
cout<<endl;
}
㈧ 求c++课程设计源代码!
第三个题目画笔行不行啊?
第二个题目我本来就发过啊。
㈨ C语言课程设计的源代码在哪里有下载啊
http://wstatic.xunlei.com/index2.htm?search=C语言来源
看看这儿有吗?
㈩ 求 c++课程设计源代码
这些都有包括课程设计,程序源码+设计报告。
第四章详细设计
#include "fstream"
#include "iostream"
#include "cstring"
using namespace std;
/************************学生信息定义**********************************/
typedef struct Stu
{ char name[8];
char num[6];
char room[5];
}Stu;
typedef struct{
Stu *elem;
int length;
}Snode;
/*****************************学生信息处理及用户交互****************/
int Init_Stu(Snode &st); //创建学生信息
int Sort_Stu(Snode &st,int low,int high); //快速排序算法
int Search_Stu(Snode st, char sn[]); //学生姓名二分查找并输出
void s(Stu &s1,Stu s2); //结构体s2赋给s1
int display(Snode st); //学生数据输出
void SavePass(); //密码问题
int quanxian(); //管理员登陆
/*******************************主函数程序****************************/
int main()
{ int suc=0;
char ch1,choice,look[10];
Snode stu;
while(suc==0)
{ suc=quanxian();
if(suc==0)
{ cerr<<"您输入的用户信息不存在,请重新输入:"<<endl<<"退出输入'y'或 'Y',否则'n'或'N':"<<endl<<endl;
cin>>ch1;
if(ch1=='y'||ch1=='Y')
return 0;
}
cout<<endl<<endl<<endl<<endl;
}
cout<<"\t\t****\n\n\t\t\t 欢迎进入学生宿舍管理查询系统 \n\n\t\t****\n\n";
cout<<"\t\t\t***************主菜单***************\n\n";
cout<<"\t\t\t\t1> 学生信息录入\n\n";