c語言大程序
Ⅰ 求一個c語言大程序
#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<stdlib.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
int num;
char name[10];
int score;
struct student *next;
};
int n;
struct student *creat()
{
struct student *head;
struct student *p1,*p2;
p1=p2=(struct student *)malloc(LEN);
printf("請輸入數據:\n");
printf("-學號---姓名---成績-\n");
scanf("%d%s%d",&p1->num,p1->name,&p1->score);
head=NULL;
n=0;
while(p1->num!=NULL)
{
n=n+1;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%d%s%d",&p1->num,p1->name,&p1->score);
}
p2->next=NULL;
return(head);
}
void print(struct student *head)
{
struct student *p;
p=head;
if(head!=NULL)
{
printf("-學號---姓名---成績-\n");
while(p!=NULL)
{
printf("%d %s %d\n",p->num,p->name,p->score);
p=p->next;
}
}
else printf("沒有數據 !\n");
}
struct student *del(int num,struct student *head)
{
int a=0;
struct student *p1,*p2;
do
{
p1=head;
if(head==NULL)
{
printf("沒有數據 !\n");
goto end;
}
while(p1->num!=num&&p1->next!=NULL)
{
p2=p1;p1=p1->next;
}
if(p1->num==num)
{
if(p1==head) head=p1->next;
else p2->next=p1->next;
printf("刪除記錄學號為N0.%d\n",num);
n=n-1;
a++;
}
}while(p1->next!=NULL);
if(a==0)
printf("學號未找到 !\n");
end:
return(head);
}
struct student *add(int num,char name[],int score,struct student *head)
{
struct student *p0,*p1,*p2;
p0=(struct student *)malloc(LEN);
p0->num=num,strcpy(p0->name,name),p0->score=score;
p1=head;
if(num==0)
return(head);
if(head==NULL)
{
head=p0;
p0->next=NULL;
}
while(p0->num>p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(p0->num<=p1->num)
{
if(p1==head) head=p0;
else p2->next=p0;
p0->next=p1;
}
else
{
p1->next=p0;
p0->next=NULL;
}
printf("增加記錄學號為:%d\n",num);
n=n+1;
return(head);
}
void num(struct student *head)
{
int num,a=0;
struct student *p;
printf("------請輸入 \"0\" 結束輸入--------\n");
do
{
p=head;
printf("請輸入要查找的學號:");
scanf("%d",&num);
if(num!=0)
printf("-學號---姓名---成績-\n");
while(p!=NULL)
{
if(p->num==num)
{
printf("%d %s %d\n",p->num,p->name,p->score);
a++;
}
p=p->next;
}
if(a==0&num!=0)
printf("學號沒找到!\n");
a=0;
}while(num!=0);
system("cls");
}
void name(struct student *head)
{
char name[10],a=0;
struct student *p;
printf("------請輸入 \"0\" 結束輸入------\n");
do
{
p=head;
printf("請輸入要查找的名字:");
scanf("%s",name);
if(name[0]!='0')
printf("-學號---姓名---成績-\n");
while(p!=NULL)
{
if(strcmp(p->name,name)==0)
{
printf("%d %s %d\n",p->num,p->name,p->score);
a++;
}
p=p->next;
}
if(a==0&&name[0]!='0')
printf("名字未找到 !\n");
a=0;
}while(name[0]!='0');
system("cls");
}
void search(struct student *head)
{
int a;
struct student *p;
p=head;
do
{
printf("1.按學號查找\n2.按名字查找\n3.退出\n");
scanf("%d",&a);
system("cls");
switch(a)
{
case 1:num(p);break;
case 2:name(p);break;
}
}while(a!=3);
}
struct student *sort(struct student *head)
{
struct student *p1,*p2;
int i,j;
int num0,score0;
char string[10];
for(i=0;i<n-1;i++)
{
p1=head;
for(j=n-1;j>0;j--)
while(p1->next!=NULL)
{
p2=p1;p1=p1->next;
if(p2->score>p1->score)
{
num0=p1->num;
p1->num=p2->num;
p2->num=num0;
strcpy(string,p1->name);
strcpy(p1->name,p2->name);
strcpy(p2->name,string);
score0=p1->score;
p1->score=p2->score;
p2->score=score0;
}
}
}
return(head);
}
void main()
{
struct student *head=NULL;
int num,score,a;
char name[10];
do
{
printf("1.創建記錄\n2.刪除記錄\n3.增加記錄\n4.查找記錄\n5按成績排序\n6.顯示當前記錄\n7.退出\n");
scanf("%d",&a);
system("cls");
switch(a)
{
case 1:printf("------請輸入 \"0 0 0\" 結束輸入------\n");head=creat();print(head);getch();system("cls");break;
case 2:printf("------請輸入 \"0\" 結束輸入--------\n");do{printf("請輸入要刪除記錄的學號:");scanf("%d",&num);head=del(num,head);print(head);}while(num!=0);system("cls");break;
case 3:printf("------請輸入 \"0 0 0\" 結束輸入------\n");do{printf("請輸入要增加的記錄數據:\n");printf("-學號---姓名---成績-\n");scanf("%d%s%d",&num,name,&score);head=add(num,name,score,head);print(head);}while(num!=0);system("cls");break;
case 4:search(head);break;
case 5:head=sort(head);print(head);getch();system("cls");break;
case 6:print(head);getch();system("cls");break;
}
}while(a!=7);
以前C語言作業課程設計,希望認真仔細看後反復自己思考,這個只是參考!C語言程序設計大作業
1題目:學生信息管理系統
2 程序要求:
(1)學生信息錄入功能
1)用戶從鍵盤輸入每個學生的信息:學號、姓名、性別、數學、英語、政治、語文四門課成績。
2)可插入一個或多個學生信息到當前編輯的班級數據中。
(2)文件保存功能
1)學生信息每一班存為一個數據文件,數據文件可在程序中打開、編輯和重新保存;
2)用戶輸入學生信息可隨時保存數據文件。
(3)文件打開功能
1)程序只能對當前打開的數據文件進行編輯。
(4)查詢功能
1)瀏覽所有學生信息;
2)按學號查詢學生信息;
3)按姓名查詢學生信息;
4) 查詢一個班總成績和平均成績;
5) 查詢一個班某一門課總成績和平均成績;
6)查詢某一門課分數段(<60,60-69,70-79,80-89,>90)學生數。
(5)報表輸出功能
1) 按學號輸出一個班學生信息:學號、姓名、性別、數學、英語、政治、語文成績、總成績,到屏幕和文件。
2) 按總成績輸出從高到低輸出學號、姓名信息。
註:以上功能以菜單形式供用戶使用,並有一定的容錯功能。
3 開發語言環境:
Macrosoft VC++6.0或Turbo C2.0
4 數據結構:
數組或鏈表
5 程序源代碼要求:
(1)函數名、變數名採用英文縮寫,使用匈牙利命名法進行自說明;
(2)源代碼的書寫採用遞進格式;
(3)程序行和程序段須有注釋。
Ⅱ 求C語言大程序設計代碼
(1)
#include<stdio.h>
#include<string.h>
void main()
{
char str[100];
int count1=0,count2=0,count3=0;
printf("input the string:\n");
scanf("%s",&str);
int size=strlen(str);
int i=0;
while(i<size)
{
if(str[i]>='a'&&str[i]<='z')
count1++;
else if(str[i]>='A'&&str[i]<='Z')
count1++;
else if(str[i]>='0'&&str[i]<='9')
count3++;
else count2++;
i++;
}
printf("長度:%d\n",size);
printf("字母 %d\n",count1);
printf("數字 %d\n",count3);
printf("其他字元 %d\n",count2);
}
(2)
#include<stdio.h>
#include<string.h>
void main()
{
char a[30][30];
char b[]="stop";
int i=0;
printf("input the string,end by string 'stop':\n");
do{
scanf("%s",&a[i]);
i++;
}while(strcmp(a[i-1],b)!=0);
int *c=new int[i];
int max=0;
for(int j=0;j<i-1;j++)
{
c[j]=strlen(a[j]);
printf("length %d\n",c[j]);
if(max<c[j])
max=c[j];
}
printf("the longest length is: %d\n",max);
}
Ⅲ c語言一個大程序,用基本語句,100句左右
# include "stdio.h"
# include "stdlib.h"
# include "string.h"
# define NULL 0
struct xiangcun
{
char num[4]; //鄉村的編號
char name[20]; //村名
int people; //總人數
int relieve; //救濟人數
float amount; //救濟總金額
struct xiangcun *next;
};
struct jiating
{
char num[10]; //鄉村編號
char candidate[20]; //身份證號碼
char fname[20]; //戶主名字
char sex[2]; //性別
int fpeople; //家庭人數
float insert; //年收入
int time; //接受救助次數
struct jiating * next;
};
struct out
{
char candidate[20]; //戶主身份證號碼
char goodsname[20]; //商品名字
char date[15]; //發放日期
char unit[10]; //單位
float price; //單價
int count; //發放數量
float money; //金額
struct out *next;
};
struct xiangcun *h1,*tail1;
struct jiating *h2,*tail2;
struct out *h3,*tail3;
struct xiangcun * rebuilt1() //構建鄉村鏈表
{
int n1=0;
struct xiangcun *p1,*p2,*head;
p1=p2=(struct xiangcun *)malloc(sizeof(struct xiangcun));
printf("\n\n\n\n\n\n 請輸入以下信息:\n 鄉村的編號:\n 村名:\n 總人數:\n 救濟人數:\n 就系總金額:\n");
scanf("%s%s%d%d%f",p1->num,p1->name,&p1->people,&p1->relieve,&p1->amount);
while(strcmp(p1->num,"0")!=0)
{
n1++;
if(n1==1)
h1=p1;
else
p2->next=p1;
p2=p1;
p1=(struct xiangcun *)malloc(sizeof(struct xiangcun));
scanf("%s%s%d%d%f",p1->num,p1->name,&p1->people,&p1->relieve,&p1->amount);
}
p2->next=NULL;
return h1;
}
struct jiating * rebuilt2() //構建家庭信息鏈表
{
int n2=0;
struct jiating *p1,*p2,*head;
p1=p2=(struct jiating *)malloc(sizeof(struct jiating));
printf("\n\n\n\n\n\n 請輸入以下信息:\n 鄉村名字: \n 戶主身份證號碼: \n 戶主名字:\n 戶主性別:\n 家庭人數:\n 年收入:\n 接受救助的次數:\n");
scanf("%s%s%s%s%d%f%d",p1->num,p1->candidate,p1->fname,p1->sex,&p1->fpeople,&p1->insert,&p1->time);
while(strcmp(p1->candidate,"0")!=0)
{
n2++;
if(n2==1)
h2=p1;
else
p2->next=p1;
p2=p1;
p1=(struct jiating *)malloc(sizeof(struct jiating));
scanf("%s%s%s%s%d%f%d",p1->num,p1->candidate,p1->fname,p1->sex,&p1->fpeople,&p1->insert,&p1->time);
}
p2->next=NULL;
return h2;
}
struct out * rebuilt3() //構建物資信息鏈表
{
struct out *p1, *p2,*head;
int n3=0;
p1=p2=(struct out *)malloc(sizeof(struct out));
printf("\n\n\n\n\n\n 請輸入以下信息:\n 戶主身份證號碼:\n 商品名字:\n 發放日期:\n 單位:\n 單價:\n 發放數量:\n 金額:\n");
scanf("%s%s%s%s%f%d%f",p1->candidate,p1->goodsname,p1->date,p1->unit,&p1->price,&p1->count,&p1->money);
while(strcmp(p1->candidate,"0")!=0)
{
n3++;
if(n3==1)
h3=p1;
else
p2->next=p1;
p2=p1;
p1=(struct out *)malloc(sizeof(struct out));
scanf("%s%s%s%s%f%d%f",p1->candidate,p1->goodsname,p1->date,p1->unit,&p1->price,&p1->count,&p1->money);
}
p2->next=NULL;
return h3;
}
int change1(xiangcun *head1,char *num) //對鄉村信息的修改
{
struct xiangcun *p;
p=head1->next;
printf("\n\n\n\n\n\n");
while(1)
{
if(p==NULL)
{
return 1;
}
if(strstr(p->num,num))
{
printf(" 請重新輸入要修改鄉村的各項:");
scanf("%s%s%d%d%d",p->num,p->name,&p->people,&p->relieve,&p->amount);
return 1;
}
p=p->next;
}
}
int change2(jiating *head2,char *num) //對家庭信息的修改
{
struct jiating *p;
p=head2->next;
printf("\n\n\n\n\n\n");
while(1)
{
if(p==NULL)
{
return 1;
}
if(strstr(p->fname,num))
{
printf(" 請重新輸入要修改家庭的各項:");
scanf("%s%s%s%s%d%f%d",p->num,p->candidate,p->fname,p->sex,&p->fpeople,&p->insert,&p->time);
return 1;
}
p=p->next;
}
}
int change3(out *head3,char *name) //對物資信息的修改
{
struct out *p;
p=head3->next;
printf("\n\n\n\n\n\n");
while(1)
{
if(p==NULL)
{
return 1;
}
if(strstr(p->goodsname,name))
{
printf(" 請重新輸入要修改物資的各項:");
scanf("%s%s%s%s%f%d%f",p->candidate,p->goodsname,p->date,p->unit,&p->price,&p->count,&p->money);
return 1;
}
p=p->next;
}
}
void Csearch(xiangcun* head1) /* 查詢全部鄉村中每個村的救濟總戶數*/
{
struct xiangcun *p;
p=head1->next;
printf("\n\n\n\n\n\n");
if(p==NULL)
{
printf(" 全鄉沒有被救濟的人!\n");
return ;
}
while(p!=NULL)
{
printf(" %s救濟人數為:%d\n",p->name,p->relieve);
p=p->next;
}
return ;
}
int Esearch(xiangcun * head1,char *name) /*查詢全部鄉村中某個村的村救濟總金額*/
{
struct xiangcun *p;
p=head1->next;
while(1)
{
if(p==NULL)
{
return 0;
}
if(strstr(p->name,name))
{
printf("\n\n\n\n\n\n %s的受救濟總金額是:%g\n",p->name,p->amount);
return 1;
}
p=p->next;
}
}
int Fsearch(jiating* head2,char * name) /*查詢某救濟戶 (如:張三)基本信息*/
{
struct jiating *p;
p=head2->next;
while(1)
{
if(p==NULL)
{
return 0;
}
if(strstr(p->fname,name))
{
printf("\n\n\n\n\n\n 戶主的鄉村編號:%s\n 戶主的身份證號碼:%s\n",p->num,p->candidate);
printf(" 戶主名字是:%s\n 戶主性別是:%s\n",p->fname,p->sex);
printf(" 家庭人數:%d\n 年收入:%g\n /接受救助次數:d\n",p->fpeople,p->insert,p->time);
return 1;
}
p=p->next;
}
}int frelieve(jiating *head2,out *head3,char * name)/*查詢某救濟戶 (如:張三)救濟戶物資發放的全部信息*/
{
struct jiating * p;
p=head2->next;
while(1)
{
if(p==NULL)
{
return 0;
}
if(strstr(p->fname,name))
{
struct out *p1;
p1=head3->next;
printf("\n\n\n\n\n\n %s的物資信息:\n",p->fname);
while(1)
{
if(p1==NULL)
{
return 1;
}
if(strstr(p->candidate,p1->candidate))
{
printf("物資名字:%s\n發放日期:%s\n物資的量的單位:%s\n",p1->goodsname,p1->date,p1->unit);
printf(" 物資單價:%g\n 發放數量:%d\n 發放金額:%g\n",p1->price,p1->count,p1->money);
}
p1=p1->next;
}
}
p=p->next;
}
}
int Relieve(jiating * head2,out *head3,char * name,char *name2)/*查詢某救濟戶 (如:張三)是否發放了某種救濟物資 (如:礦泉水)的信息*/
{
struct jiating * p;
p=head2->next;
while(1)
{
if(p==NULL)
{
return 0;
}
if(strstr(p->fname,name))
{
out *p1;
p1=head3->next;
while (1)
{
if(strstr(p->candidate,p1->candidate)&&strstr(p1->goodsname,name2))
{
return 1;
}
p1=p1->next;
if(p1==NULL)
{
return 0;
}
}
}
p=p->next;
}
}
void tprint(xiangcun * head1)/*統計並輸出全鄉的人口總數、救濟總戶數、救濟總金額*/
{
int peo_sum=0,re_sum=0;
float re_cost=0;
xiangcun *p=h1;
while(p!=NULL)
{
peo_sum+=p->people;
re_sum+=p->relieve;
re_cost+=p->amount;
p=p->next;
}
printf("\n\n\n\n\n\n 人口總數:%d\n 救濟總戶數:%d\n 救濟總金額:%g\n",peo_sum,re_sum,re_cost);
}
將題目存為文本文件,要查看題目、看源代碼就直接讀文件顯示出來 將需要運行的程序都單獨編譯成可執行文件 在大程序里用 winexec("D:\\hello.exe",SW_SHOWNORMAL); 即可運行可執行文件 注意包含頭文件#include <windows.h>,但是不能在TC下編譯,必須使用dev-c++或vc++編譯,不過這是純粹的C代碼
Ⅳ 什麼是C語言程序
通用編程語言c
c語言是美國at&t(電報與電話)公司為了實現unix系統的設計思想而發展起來的語言工具。c語言的主要特色是兼顧了高級語言和匯編語言的特點,簡潔、豐富、可移植。相當於其他高級語言子程序的函數是c語言的補充,每一個函數解決一個大問題中的小任務,函數使程序模塊化。c語言提供了結構式編程所需要的各種現代化的控制結構。
c語言是一種通用編程語言,正被越來越多的計算機用戶所推崇。使用c語言編寫程序,既感覺到使用高級語言的自然,也體會到利用計算機硬體指令的直接,而程序員卻無需捲入匯編語言的繁瑣。
c語言可以用來製作病毒,因為病毒也是程序.
Ⅵ 用C語言編寫一個大的程序
不好一下就可以編好,除非有很大的報酬。
沒有人楞到給你浪費一周的供粻垛救艹嚼訛楔番盲時間去寫1000行的c語言程序
Ⅶ 如何編寫C語言程序
准備材料
windows電腦、VC++(DEV_C++)
1.打開桌面上的DEV_C++,進入如下界面:
Ⅷ 為什麼大型程序很多都用C語言來編寫呢
C語言是目前世界上流行、使用最廣泛的高級程序設計語言。
C語言對操作系統和系統使用程序以及需要對硬體進行操作的場合,用C語言明顯優於其它高級語言,許多大型應用軟體都是用C語言編寫的。
C語言具有繪圖能力強,可移植性,並具備很強的數據處理能力,因此適於編寫系統軟體,三維,二維圖形和動畫它是數值計算的高級語言。
常用的編譯軟體有Microsoft Visual C++,Borland C++,Watcom C++ ,Borland C++, Borland C++ Builder,Borland C++ 3.1 for DOS,Watcom C++ 11.0 for DOS,GNU DJGPP C++, Lccwin32 C Compiler 3.1,Microsoft C,High C,等等......
C語言的發展歷史
C語言的發展頗為有趣。它的原型ALGOL 60語言。
1963年,劍橋大學將ALGOL 60語言發展成為CPL(Combined Programming Language)語言。
1967年,劍橋大學的Matin Richards 對CPL語言進行了簡化,於是產生了BCPL語言。
1970年,美國貝爾實驗室的Ken Thompson將BCPL進行了修改,並為它起了一個有趣的名字「B語言」。意思是將CPL語言煮干,提煉出它的精華。並且他用B語言寫了第一個UNIX操作系統。
而在1973年,B語言也給人「煮」了一下,美國貝爾實驗室的D.M.RITCHIE在B語言的基礎上最終設計出了一種新的語言,他取了BGPL的第二個字母作為這種語言的名字,這就是C語言。
為了使UNIX操作系統推廣,1977年Dennis M.Ritchie 發表了不依賴於具體機器系統的C語言編譯文本《可移植的C語言編譯程序》。
1978年Brian W.Kernighian和Dennis M.Ritchie出版了名著《The C Programming Language》,從而使C語言成為目前世界上流行最廣泛的高級程序設計語言。
1988年,隨著微型計算機的日益普及, 出現了許多C語言版本。由於沒有統一的標准,使得這些C語言之間出現了一些不一致的地方。為了改變這種情況,美國國家標准研究所(ANSI)為C語言制定了一套ANSI標准, 成為現行的C語言標准 3.C語言的主要特點 。C語言發展迅速, 而且成為最受歡迎的語言之一, 主要因為它具有強大的功能。許多著名的系統軟體, 如DBASE Ⅲ PLUS、DBASE Ⅳ 都是由C 語言編寫的。用C語言加上一些匯編語言子程序, 就更能顯示C語言的優勢了,象PC- DOS 、WORDSTAR等就是用這種方法編寫的。
C語言的特點
1. 簡潔緊湊、靈活方便
C語言一共只有32個關鍵字,9種控制語句,程序書寫自由,主要用小寫字母表示。它把高級語言的基本結構和語句與低級語言的實用性結合起來。 C 語言可以象匯編語言一樣對位、位元組和地址進行操作, 而這三者是計算機最基本的工作單元。
2. 運算符豐富
C的運算符包含的范圍很廣泛,共有種34個運算符。C語言把括弧、賦值、強制類型轉換等都作為運算符處理。從而使C的運算類型極其豐富表達式類型多樣化,靈活使用各種運算符可以實現在其它高級語言中難以實現的運算。
3. 數據結構豐富
C的數據類型有:整型、實型、字元型、數組類型、指針類型、結構體類型、共用體類型等。能用來實現各種復雜的數據類型的運算。並引入了指針概念,使程序效率更高。另外C語言具有強大的圖形功能, 支持多種顯示器和驅動器。且計算功能、邏輯判斷功能強大。
4. C是結構式語言
結構式語言的顯著特點是代碼及數據的分隔化,即程序的各個部分除了必要的信息交流外彼此獨立。這種結構化方式可使程序層次清晰, 便於使用、維護以及調試。C語言是以函數形式提供給用戶的,這些函數可方便的調用,並具有多種循環、條件語句控製程序流向,從而使程序完全結構化。
5. C語法限制不太嚴格、程序設計自由度大
一般的高級語言語法檢查比較嚴,能夠檢查出幾乎所有的語法錯誤。而C語言允許程序編寫者有較大的自由度。
6. C語言允許直接訪問物理地址,可以直接對硬體進行操作
因此既具有高級語言的功能,又具有低級語言的許多功能,能夠象匯編語言一樣對位、位元組和地址進行操作,而這三者是計算機最基本的工作單元,可以用來寫系統軟體。
7. C語言程序生成代碼質量高,程序執行效率高
一般只比匯編程序生成的目標代碼效率低10へ20%。
8. C語言適用范圍大,可移植性好
C語言有一個突出的優點就是適合於多種操作系統, 如DOS、UNIX,也適用於多種機型。
轉自:太平洋電腦網
Ⅸ 求簡單C語言程序代碼!
輸入2個正整數m和n,求其最大公約數和最小公倍數
#include
#include
int main()
int m,n,p,q,s,r;
printf("請輸入兩個正整數;m,n ");
scanf("%d,%d",&m,&n);
#include<stdio.h>
main()
int a,b,t=0;
scanf("%d %d",&a,&b);
if (a<b)
printf("%d %d %d %d %d",(a+b),(a-b),(a/b),(a*b),(a%b));
}
主要特點
C語言是一種結構化語言,它有著清晰的層次,可按照模塊的方式對程序進行編寫,十分有利於程序的調試,且c語言的處理和表現能力都非常的強大,依靠非常全面的運算符和多樣的數據類型,可以輕易完成各種數據結構的構建,通過指針類型更可對內存直接定址以及對硬體進行直接操作,因此既能夠用於開發系統程序,也可用於開發應用軟體。
以上內容參考:網路-c語言