主要程序代碼有 單片機與LED數碼管接口 LED大屏幕顯示器和接口 字符LCD 液晶顯示和接口 單片機與鍵盤接口 A/D轉換器接口 D/A 轉換器接口 串行通信基礎 MCS-51的串行接口 MCS-51單片機雙機通信 RS-232C串行通信總線標準及其接口 存儲器的擴展 串行口的I/O口擴展 數字鐘的設計與制作 單片機溫度檢測記錄系統
上傳時間: 2016-04-12
上傳用戶:eruth
#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*運動員*/ { char name[20]; int score; /*分數*/ int range; /**/ int item; /*項目*/ }ATH; typedef struct schoolstruct /*學校*/ { int count; /*編號*/ int serial; /**/ int menscore; /*男選手分數*/ int womenscore; /*女選手分數*/ int totalscore; /*總分*/ ATH athlete[MaxSize]; /**/ struct schoolstruct *next; }SCH; int nsc,msp,wsp; int ntsp; int i,j; int overgame; int serial,range; int n; SCH *head,*pfirst,*psecond; int *phead=NULL,*pafirst=NULL,*pasecond=NULL; void create(); void input () { char answer; head = (SCH *)malloc(sizeof(SCH)); /**/ head->next = NULL; pfirst = head; answer = 'y'; while ( answer == 'y' ) { Is_Game_DoMain: printf("\nGET Top 5 when odd\nGET Top 3 when even"); printf("\n輸入運動項目序號 (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n這個項目已經存在請選擇其他的數字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { printf("\n項目不存在"); printf("\n請重新輸入"); goto Is_Game_DoMain; } switch ( overgame%2 ) { case 0: n = 3;break; case 1: n = 5;break; } for ( i = 1 ; i <= n ; i++ ) { Is_Serial_DoMain: printf("\n輸入序號 of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { printf("\n超過學校數目,請重新輸入"); goto Is_Serial_DoMain; } if ( head->next == NULL ) { create(); } psecond = head->next ; while ( psecond != NULL ) { if ( psecond->serial == serial ) { pfirst = psecond; pfirst->count = pfirst->count + 1; goto Store_Data; } else { psecond = psecond->next; } } create(); Store_Data: pfirst->athlete[pfirst->count].item = overgame; pfirst->athlete[pfirst->count].range = i; pfirst->serial = serial; printf("Input name:) : "); scanf("%s",pfirst->athlete[pfirst->count].name); } printf("\n繼續輸入運動項目(y&n)?"); answer = getchar(); printf("\n"); } } void calculate() /**/ { pfirst = head->next; while ( pfirst->next != NULL ) { for (i=1;i<=pfirst->count;i++) { if ( pfirst->athlete[i].item % 2 == 0 ) { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 5;break; case 2:pfirst->athlete[i].score = 3;break; case 3:pfirst->athlete[i].score = 2;break; } } else { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 7;break; case 2:pfirst->athlete[i].score = 5;break; case 3:pfirst->athlete[i].score = 3;break; case 4:pfirst->athlete[i].score = 2;break; case 5:pfirst->athlete[i].score = 1;break; } } if ( pfirst->athlete[i].item <=msp ) { pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score; } else { pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score; } } pfirst->totalscore = pfirst->menscore + pfirst->womenscore; pfirst = pfirst->next; } } void output() { pfirst = head->next; psecond = head->next; while ( pfirst->next != NULL ) { // clrscr(); printf("\n第%d號學校的結果成績:",pfirst->serial); printf("\n\n項目的數目\t學校的名字\t分數"); for (i=1;i<=ntsp;i++) { for (j=1;j<=pfirst->count;j++) { if ( pfirst->athlete[j].item == i ) { printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break; } } } printf("\n\n\n\t\t\t\t\t\t按任意建 進入下一頁"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n運動會結果:\n\n學校編號\t男運動員成績\t女運動員成績\t總分"); pfirst = head->next; while ( pfirst->next != NULL ) { printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore); pfirst = pfirst->next; } printf("\n\n\n\t\t\t\t\t\t\t按任意建結束"); getchar(); } void create() { pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct)); pfirst->next = head->next ; head->next = pfirst ; pfirst->count = 1; pfirst->menscore = 0; pfirst->womenscore = 0; pfirst->totalscore = 0; } void Save() {FILE *fp; if((fp = fopen("school.dat","wb"))==NULL) {printf("can't open school.dat\n"); fclose(fp); return; } fwrite(pfirst,sizeof(SCH),10,fp); fclose(fp); printf("文件已經成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 運動會分數統計\n"); printf("輸入學校數目 (x>= 5):"); scanf("%d",&nsc); printf("輸入男選手的項目(x<=20):"); scanf("%d",&msp); printf("輸入女選手項目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
標簽: 源代碼
上傳時間: 2016-12-28
上傳用戶:150501
%球體 close all; G=6.67e-11; R=2;%球體半徑 p=4.0;%密度 D=10.0;%深度 M=(4/3)*pi*R^3*p;%質量 x=-20:1:20; g=G*M*D./((x.^2+D^2).^(3/2)); Vxz=-3*G*M*D.*x./((x.^2+D^2).^(5/2)); Vzz=G*M.*(2*D^2-x.^2)./((x.^2+D^2).^(5/2)); Vzzz=3*G*M.*(2*D^2-3.*x.^2)./((x.^2+D^2).^(7/2)); subplot(2,2,1) plot(x,g,'k-'); xlabel('水平距離(m)'); ylabel('重力異常值'); title('球體重力異常Δg'); grid on subplot(2,2,2) plot(x,Vxz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vxz'); grid on subplot(2,2,3) plot(x,Vzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzz'); grid on subplot(2,2,4); plot(x,Vzzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzzz'); grid on %% %水平圓柱體 close all G=6.67e-11; p=10.0;%線密度 D=100.0;%深度 x=-200:1:200; g=G*2*p*D./(x.^2+D^2); Vxz=4*G*p*D.*x./(x.^2+D^2).^2; Vzz=2*G*p.*(D^2-x.^2)./(x.^2+D^2).^2; Vzzz=4*G*p.*(D^2-3.*x.^2)./((x.^2+D^2).^3); subplot(2,2,1) plot(x,g,'k-'); xlabel('水平距離(m)'); ylabel('重力異常值'); title('水平圓柱體重力異常Δg'); grid on subplot(2,2,2) plot(x,Vxz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vxz'); grid on subplot(2,2,3) plot(x,Vzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzz'); grid on subplot(2,2,4); plot(x,Vzzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzzz'); grid on %% %垂直臺階 G=6.67e-11; p=4.0;%密度 h1=50.0;%下層深度 h2=40.0;%上層深度 x=-100:1:100; g=G*p.*(pi*(h1-h2)+x.*log((x.^2+h1^2)./(x.^2+h2^2))+2*h1.*atan(x./h1)-2*h2.*atan(x./h2)); Vxz=G*p.*log((h1^2+x.^2)./(h2^2+x.^2)); Vzz=2*G*p.*atan((x.*(h1-h2))./(x.^2+h1*h2)); Vzzz=2*G*p.*x*(h1^2-h2^2)./((h1^2+x.^2).*(x.^2+h2^2)); subplot(2,2,1) plot(x,g,'k-'); xlabel('水平距離(m)'); ylabel('重力異常值'); title('垂直臺階重力異常Δg'); grid on subplot(2,2,2) plot(x,Vxz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vxz'); grid on subplot(2,2,3) plot(x,Vzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzz'); grid on subplot(2,2,4); plot(x,Vzzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzzz'); grid on %% %傾斜臺階 G=6.67e-11; p=4.0;%密度 h1=50.0;%下層深度 h2=40.0;%上層深度 a=pi/6;%傾斜角度 x=-500:1:500; g=G*p.*(pi*(h1-h2)+2*h1.*atan((x+h1*cot(a))./h1)-2*h2.*atan((x+h2*cot(a))./h1)+x.*sin(a)^2.*log(((h1+x.*sin(a).*cos(a)).^2+x.^2.*sin(a)^4)./((h2+x.*(sin(a)*cos(a))).^2+x.^2.*sin(a)^4))); Vxz=G*p.*(sin(a)^2.*log(((h1*cot(a)+x).^2+h1^2)./((h2*cot(a)+x).^2+h2^2))-2*sin(2*a).*(atan((h1/sin(a)+x.*cos(a))./(x.*sin(a)))-atan((h2/sin(a)+x.^cos(a))./(sin(a).*x)))); Vzz=G*p.*(0.5*sin(2*a)^2.*log(((h1*cot(a)+x).^2+h1^2)./((h2*cot(a)+x).^2+h2^2))+2*sin(a)^2.*(atan((h1/sin(a)+x.*cos(a))./(x.*sin(a)))-atan((h2/sin(a)+x.*cos(a))./(x.*sin(a))))); Vzzz=2*G*p*sin(a)^2.*((x+2*h2*cot(a))./((h2*cot(a)+x).^2+h2^2)-(x+2*h1*cot(a))./((h1*cot(a)+x).^2+h1^2)); subplot(2,2,1) plot(x,g,'k-'); xlabel('水平距離(m)'); ylabel('重力異常值'); title('傾斜臺階重力異常Δg'); grid on subplot(2,2,2) plot(x,Vxz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vxz'); grid on subplot(2,2,3) plot(x,Vzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzz'); grid on subplot(2,2,4); plot(x,Vzzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzzz'); grid on %% %鉛錘柱體 G=6.67e-11; p=4.0;%密度 h1=50.0;%下層深度 h2=40.0;%上層深度 a=3;%半徑 x=-500:1:500; g=G*p.*((x+a).*log(((x+a).^2+h1^2)./((x+a).^2+h2^2))-(x-a).*log(((x-a).^2+h1^2)./((x-a).^2+h2^2))+2*h1.*(atan((x+a)./h1)-atan((x-a)./h1))-2*h2.*(atan((x+a)./h2)-atan((x-a)./h2))); Vxz=G*p.*log((((x+a).^2+h1^2).*((x-a).^2+h2^2))./(((x+a).^2+h2^2).*((x-a).^2+h1^2))); Vzz=2*G*p.*(atan(h1./(x+a))-atan(h2./(x+a))-atan(h1./(x-a))+atan(h2./(x-a))); Vzzz=2*G*p.*((x+a)./((x+a).^2+h2^2)-(x+a)./((x+a).^2+h1^2)-(x-a)./((x-a).^2+h2^2)+(x-a)./((x-a).^2+h1^2)); subplot(2,2,1) plot(x,g,'k-'); xlabel('水平距離/m') ylabel('重力異常值') title('鉛垂柱體重力異常') grid on subplot(2,2,2) plot(x,Vxz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vxz'); grid on subplot(2,2,3) plot(x,Vzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzz'); grid on subplot(2,2,4); plot(x,Vzzz); xlabel('水平距離(m)'); ylabel('導數值'); title('Vzzz'); grid on
上傳時間: 2019-05-10
上傳用戶:xiajiang
程控可編程線性電源廣泛應用于集成電路測試和各種實驗過程中,電源的性能、可靠性和易操作性是其關鍵指標。本文以ATmega128單片機為控制核心,以ADS8341模數轉換器、 AD5624數模轉換器,設計了一款三通道輸出的程控可編程線性電源樣機。闡述該電源的系統架構、結構、操作系統、液晶顯示界面以及通信協議等設計內容。對樣機進行了測試,給出了該電源的常用指標,該樣機已長時間應用于高速高精度A/D轉換器和D/A轉換器的測試中。
上傳時間: 2022-03-28
上傳用戶:canderile
A) 實現虛擬存儲B) 實現對文件的按名存取C) 實現對文件的按內容存取D) 實現對文件的 高速輸入輸出(17) 分頁顯示當前文件 ... A) 執行SPLIB B) 執行SPDOS C) 裝載拼音模塊D) 裝載五筆字型輸入模塊(32) 在漢字輸入狀態下,按下Shift+a組合鍵后,輸入了__。
上傳時間: 2013-12-23
上傳用戶:zhoujunzhen
A.執行SPLIB B.執行SPDOS C.裝載拼音模塊D.裝載五筆字型輸入模塊32.在漢字輸入狀態下, 按下Shift+A組合鍵后,輸入了_______。 ... A.按原代碼方式B.按指定字體C.按標準方式D. 按分欄方式41.FoxBASE啟動后,在圓點"."提示符下,執行命令文件MAIN.
上傳時間: 2015-04-02
上傳用戶:極客
將A、B、C、D、E、F這六個變量排成如圖所示的三角形,這六個變量分別取[1,6]上的整數,且均不相同。求使三角形三條邊上的變量之和相等的全部解。如圖就是一個解。
上傳時間: 2013-12-16
上傳用戶:GHF
學生成績管理系統功能簡介 a. 查詢指定學號學生成績記錄。 b. 按平均分順序插入一個新的學生成績。 c. 刪除指定學號學生記錄。 d. 修改指定學號學生成績記錄。 e. 在屏幕上輸出所有學生的成績。 f. 將學生成績輸出到文件。
上傳時間: 2015-06-06
上傳用戶:葉山豪
介紹一個基于U S B 2 . 0 接口和D S P 的高速數據采集處理系統的工作原理設計及實現該高速數據 采集處理系統采用TI 公司的TMS320C6000 數字信號處理器和Cypress 公司的USB2.0 接口芯片可 以實現高速采集和實時處理有著廣泛的應用前景
上傳時間: 2013-11-27
上傳用戶:koulian
四選一選擇器,輸入四個,輸出1個.當NM=00時選A 當NM=01時選B 當NM=10時選C 當NM=11時選D
上傳時間: 2013-12-25
上傳用戶:woshiayin