当前位置:首页 > 代码 > 正文

c项目实战源代码(c语言项目源代码)

admin 发布:2022-12-19 11:35 89


本篇文章给大家谈谈c项目实战源代码,以及c语言项目源代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

求几个比较有趣,简单的C语言源代码 小白自己敲着练一下手感

最简单的模拟计时器:

#includestdio.h

#includeconio.h

#includewindows.h

int m=0,s=0,ms=0;  //m是分 s是秒 ms是毫秒

//以下是5个自编函数

void csh( );  //初始化界面

void yinc(int x,int y);  //隐藏光标的函数(y值设为0就会隐藏)

void jishi( );  //计时器运行(每100毫秒变化一次)

void Color (short x, short y);  //设定颜色的函数(y设为0就是黑底)

void gtxy (int x, int y);  //控制光标位置的函数

int main(  )  //主函数

{  csh( );

   getch( );

   while(1)

       { jishi( );

         Sleep(100);  //间隔100毫秒

         if( kbhit( ) )break;  //有键按下就退出循环

       }

    return 0;

}

void csh( )   //初始化界面

{Color(14,0);    //设定淡黄字配黑底

printf(“\n\n\t    计时器”);

Color(10,0);   //设定淡绿字配黑底

printf("\n\t┌───────────┐");

printf("\n\t│           │");

printf("\n\t└───────────┘");

gtxy(10,4);   //光标到屏幕第10列4行处输出

Color(7,0);   //恢复白字黑底

printf(" 00:00:00 ");

yinc(1,0 );   //隐藏光标(yinc代表隐藏)

return;

}

void jishi( )  //计时器运行

{ms+=1;

if(ms==10){s+=1;ms=0;}

if(s==60){m+=1;s=0;}

gtxy(10,4);

Color(9,0);   //设定淡蓝字配黑底

if(m9) printf(" %d:",m);

else printf(" 0%d:",m);

Color(14,0);   //设定淡黄字配黑底

if(s9) printf("%d:",s);

else printf("0%d:",s);

Color(12,0);   //设定淡红字配黑底

printf("0%d",ms);

}

void gtxy (int x, int y)   //控制光标位置的函数

{ COORD pos;

pos.X = x;

pos.Y = y;

SetConsoleCursorPosition ( GetStdHandle (STD_OUTPUT_HANDLE), pos );

}

void Color (short ForeColor= 7, short BackGroundColor= 0)   //设定颜色的函数

{ HANDLE  handle = GetStdHandle ( STD_OUTPUT_HANDLE );

SetConsoleTextAttribute ( handle, ForeColor + BackGroundColor * 0x10 );

}

void yinc(int x,int y)   //隐藏光标的设置(gb代表光标)

{ CONSOLE_CURSOR_INFO  gb={x,y};   //x为1-100,y为0就隐藏光标

SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), gb);

}

求C语言源代码,指针与数组编程

1

#includestdio.h

void main()

{

int i,a[10],*p,x,n,flag=0;

p=a;

printf("请输入数组元素的个数n,n=10\n");

scanf("%d",n);

for(i=0;in;i++)

{

printf("请输入第%d个元素\n",i+1);

scanf("%d",p+i);

}

printf("请输入要查找的数字\n");

scanf("%d",x);

for(i=0;in;i++)

if(*(p+i)==x)

{

printf("查找成功,下标为%d\n",i);

flag=1;

}

if(flag==0)

printf("Not found!\n");

}

/*你要的功能在fun函数中实现,注意参数调用的方式*/

#includestdio.h

#define N 3/*可以改*/

#define M 3/*可以改*/

void fun(double a[][M],int n,int m);

void main()

{

double a[N][M]={1,60,35,90,90,95,68,95,83};

fun(a,N,M);

}

void fun(double a[][M],int n,int m)

{

int i,k;

double *p=a[0][0];

for(i=0;in*m;i++)

if(*(p+i)60)

{

printf("%d:",i/n);

for(k=0;kM;k++)

printf("%-7.2f",*(p+i/n+k));

printf("\n");

i=i/n+k-1;

}

}

我的C语言项目是餐饮管理系统,求个源代码

include "stdio.h" /*I/O函数*/

#include "stdlib.h" /*其它说明*/

#include "string.h" /*字符串函数*/

#include "conio.h" /*屏幕操作函数*/

#include "mem.h" /*内存操作函数*/

#include "ctype.h" /*字符操作函数*/

#include "alloc.h" /*动态地址分配函数*/

struct score

{

int mingci;

char xuehao[8];

char mingzi[20];

float score[6];

}data,info[1000];

int i,j,k=0;

char temp[20],ch;

FILE *fp,*fp1;

void shuru()

{

if((fp=fopen("s_score.txt","ab+"))==NULL)

{

printf("cannot open this file.\n");

getch();exit(0);

}

for(i=0;i=1000;i++)

{

printf("\nPlease shuru xuehao:");

gets(data.xuehao);

printf("Please shuru mingzi:");

gets(data.mingzi);

printf("Please shuru yuwen score:");

gets(temp);data.score[0]=atof(temp);

printf("Please shuru shuxue score:");

gets(temp);data.score[1]=atof(temp);

printf("Please input yingyu score:");

gets(temp);data.score[2]=atof(temp);

printf("Please shuru wuli score:");

gets(temp);data.score[3]=atof(temp);

printf("Please shur huaxue score:");

gets(temp);data.score[4]=atof(temp);

data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];

fwrite(data,sizeof(data),1,fp);

printf("another?y/n");

ch=getch();

if(ch=='n'||ch=='N')

break;

} fclose(fp);

}

void xianshi()

{

float s;int n;

if((fp=fopen("s_score.txt","rb+"))==NULL)

{

printf("Cannot reading this file.\n");

exit(0);

}

for(i=0;i=1000;i++)

{

if((fread(info[i],sizeof(info[i]),1,fp))!=1)

break;

}

printf("\nxuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen\n");

for(j=0,k=1;ji;j++,k++)

{

info[j].mingci=k;

printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4],

info[j].score[5]);

}

getch();

fclose(fp);

}

void xiugai()

{

if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)

{

printf("Cannot open this file.\n");

exit(0);

}

printf("\nPLease shuru xiugai xuehao:");

scanf("%d",i); getchar();

while((fread(data,sizeof(data),1,fp))==1)

{

j=atoi(data.xuehao);

if(j==i)

{

printf("xuehao:%s\nmingzi:%s\n",data.xuehao,data.mingzi);

printf("Please shuru mingzi:");

gets(data.mingzi);

printf("Please shuru yuwen score:");

gets(temp);data.score[0]=atof(temp);

printf("Please shuru shuxue score:");

gets(temp);data.score[1]=atof(temp);

printf("Please input yingyu score:");

gets(temp);data.score[2]=atof(temp);

printf("Please input wuli score:");

gets(temp);data.score[3]=atof(temp);

printf("Please input huaxue score:");

gets(temp);data.score[4]=atof(temp);

data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];

} fwrite(data,sizeof(data),1,fp1);

}

fseek(fp,0L,0);

fseek(fp1,0L,0);

while((fread(data,sizeof(data),1,fp1))==1)

{

fwrite(data,sizeof(data),1,fp);

}

fclose(fp);

fclose(fp1);

}

void chazhao()

{

if((fp=fopen("s_score.txt","rb"))==NULL)

{

printf("\nCannot open this file.\n");

exit(0);

}

printf("\nPLease shuru xuehao chakan:");

scanf("%d",i);

while(fread(data,sizeof(data),1,fp)==1)

{

j=atoi(data.xuehao);

if(i==j)

{

printf("xuehao:%s mingzi:%s\nyuwen:%f\n shuxue:%f\n yingyu:%f\n wuli:%f\n huaxue:%f\n ",data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);

}getch();

}

}

void shanchu()

{

if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)

{

printf("\nopen score.txt was failed!");

getch();

exit(0);

}

printf("\nPlease input ID which you want to del:");

scanf("%d",i);getchar();

while((fread(data,sizeof(data),1,fp))==1)

{

j=atoi(data.xuehao);

if(j==i)

{

printf("Anykey will delet it.\n");

getch();

continue;

}

fwrite(data,sizeof(data),1,fp1);

}

fclose(fp);

fclose(fp1);

remove("s_score.txt");

rename("temp.txt","s_score.txt");

printf("Data delet was succesful!\n");

printf("Anykey will return to main.");

getch();

}

main()

{

while(1)

{

clrscr(); /*清屏幕*/

gotoxy(1,1); /*移动光标*/

textcolor(YELLOW); /*设置文本显示颜色为黄色*/

textbackground(BLUE); /*设置背景颜色为蓝色*/

window(1,1,99,99); /* 制作显示菜单的窗口,大小根据菜单条数设计*/

clrscr();

printf("*************welcome to use student manage******************\n");

printf("*************************menu********************************\n");

printf("* ========================================================= * \n");

printf("* 1shuru 2xiugai * \n");

printf("* 3shanchu 4chazhao * \n");

printf("* 5xianshi 6exit * \n");

printf("* * \n");

printf("* --------------------------------------------------------- * \n");

printf(" Please input which you want(1-6):");

ch=getch();

switch(ch)

{

case '1':shuru();break;

case '2':xiugai(); break;

case '3':shanchu(); break;

case '4':chazhao(); break;

case '5':xianshi(); break;

case '6':exit(0);

default: continue;

}

}

c语言程序代码

#includestdio.h

#define N 200

struct child

{

char name[10];

char sex[3];

int age;

int height;

float weight;

struct {

int year;

int month;

int day;

}bdate;

}ch[N];

void input()

{

int i;

for(i=0;iN;i++)

{

printf("\n请输入第%d名小朋友信息:\n",i+1);

printf("姓名:");

scanf("%s",ch[i].name);

printf("性别:");

scanf("%s",ch[i].sex);

printf("年龄:");

scanf("%d",ch[i].age);

printf("身高:");

scanf("%d",ch[i].height);

printf("体重:");

scanf("%f",ch[i].weight);

printf("出生日期[YYYY-MM-DD]:");

scanf("%d-%d-%d",ch[i].bdate.year,ch[i].bdate.month,ch[i].bdate.day);

}

}

void sort()

{

struct child ct;

int i,j;

for(i=0;iN-1;i++)

for(j=0;jN-i-1;j++)

if(ch[j].heightch[j+1].height)

{

ct=ch[j];

ch[j]=ch[j+1];

ch[j+1]=ct;

}

}

void output()

{

int i;

printf("\n\t幼儿园小朋友一览(依身高排序)\n");

printf("===================================================\n");

printf(" 姓名 性别 年龄 身高 体重 出生日期 \n");

printf("===================================================\n");

for(i=0;iN;i++)

printf(" %-8s %-2s %2d %d %3.1f %d.%d.%d\n",ch[i].name,ch[i].sex,ch[i].age,ch[i].height,ch[i].weight,ch[i].bdate.year,ch[i].bdate.month,ch[i].bdate.day);

}

void main()

{

input();

sort();

output();

}

//分给的忒少,呵呵

求c/c++ 项目实战视频,最好附有源代码

李明杰《30小时快速精通C++和外挂实战》(高清视频)百度网盘  

链接:

提取码: pchs 复制这段内容后打开百度网盘手机App,操作更方便哦   

若资源有问题欢迎追问~  

关于c项目实战源代码和c语言项目源代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/7476.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载