#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
#include<stdio.h> #include<windows.h> int xuanxiang; int studentcount; int banjihao[100]; int xueqihao[100][10]; char xm[100][100]; int xuehao[100][10]; int score[100][3]; int yuwen; int shuxue[000]; int yingyu[100]; int c[100]; int p; char x[1000][100]="",y[100][100]="";/*x學院 y專業 z班級*/ int z[100]; main() { void input(); void inputsc(); void alter(); void scbybannji(); printf("--------學生成績管理-----\n"); printf("請按相應數字鍵來實現相應功能\n"); printf("1.錄入學生信息 2.錄入學生成績 3.修改學生成績\n"); printf("4.查詢學生成績 5.不及格科目及名單 6.按班級輸出學生成績單\n"); printf("請輸入你要實現的功能所對應的數字:"); scanf("%d",&xuanxiang); system("cls"); getchar(); switch (xuanxiang) { case 1:input(); case 2:inputsc(); case 3:alter(); /*case 4:select score(); case 5:bujigekemujimingdan();*/ case 6:scbybanji; } } void input() { int i; printf("請輸入你的學院名稱:"); gets(x); printf("請輸入你的專業名稱:"); gets(y); printf("請輸入你的班級號:"); scanf("%d",&z); printf("請輸入你們一個班有幾個人:"); scanf("%d",&p); system("cls"); for(i=0;i<p;i++) { printf("請輸入第%d個學生的學號:",i+1); scanf("%d",xuehao[i]); getchar(); printf("請輸入第%d個學生的姓名:",i+1); gets(xm[i]); system("cls"); } printf("您已經錄入完畢您的班級所有學生的信息!\n"); printf("您的班級為%s%s%s\n",x,y,z); /*alter(p);*/ } void inputsc() { int i; for(i=0;i<p;i++) { printf("\n"); printf("--------------------------------------------------------------------------------\n\n"); printf("\t\t\t\t錄入學生的成績\n\n\n"); printf("--------------------------------------------------------------------------------\n\n"); printf("\t\t\t\t%s\n",xm[i]); printf("\n"); printf("\t\t\t\t數學:"); scanf("%d",&shuxue[i]); printf("\n"); getchar(); printf("\t\t\t\t英語:"); scanf("%d",&yingyu[i]); printf("\n"); getchar(); printf("\t\t\t\tc語言:"); scanf("%d",&c[i]); system("cls"); } } void alter() { int i;/*循環變量*/ int m[10000];/*要查詢的學號*/ int b;/*修改后的成績*/ char kemu[20]=""; printf("請輸入你要修改的學生的學號"); scanf("%d",&m); for (i=0;i<p;i++) { if (m==xuehao[i]) { printf("%s的數學成績為%d,英語成績為%d,c語言成績為%d,xm[i],shuxue[i],yingyu[i],c[i]"); printf("請輸入你想修改的科目");} } gets(kemu); getchar(); if (kemu=="數學"); { scanf("%d",&b); shuxue[i]=b;} if (kemu=="英語"); { scanf("%d",&b); yingyu[i]=b;} if (kemu=="c語言"); { scanf("%d",&b); c[i]=b; } printf("%s的數學成績為%d,英語成績為%d,c語言成績為%d,xm[i],shuxue[i],yingyu[i],c[i]"); } void scbybannji() { int i; char zyname[20]; int bjnumber; printf("請輸入你的專業名稱"); scanf("%s",&zyname); printf("請輸入你的班級號"); scanf("%d",&bjnumber); for (i=0;i<p;i++) { if (zyname==y[i]); if (bjnumber==z[i]); printf("專業名稱%s班級號%d數學成績%d英語成績%dc語言成績%d,y[i],z[i],shuxue[i],yingyu[i],c[i]"); } }
標簽: c語言
上傳時間: 2018-06-08
上傳用戶:2369043090
%球體 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
FOC的控制核心——坐標變換■坐標系口一定子坐標系(靜止)一A-B-C坐標系(三相定子繞組、相差120度)一a-β坐標系(直角坐標系:a軸與A軸重合、β軸超前a軸90度)口一轉子坐標系(旋轉)-d-q坐標系(d軸一轉子磁極的軸線、q軸超前d軸90度)口一定向坐標系(旋轉)M-T坐標系(M軸固定在定向的磁鏈矢量上,T軸超前M軸90度)轉子磁場定向控制一-M-T坐標系與d-q坐標系重合FOC的控制核心——SVPWM■空間矢量口根據功率管的開關狀態(上管導通是“1",關閉是“0")定義了8個空間矢量。其中000和111是零矢量。■扇區口空間矢量構成6個扇區口確定Vref位于哪個扇區,才能知道用哪對相鄰的基本電壓空間矢量去合成Vref。■參考電壓矢量合成口利用基本電壓空間矢量的線性時間組合得到定子參考電壓Vref。■七段式SVPWM,由3段零矢量和4段相鄰的兩個非零矢量組成。3段零矢量分別位于PWM的開始、中間和結尾。■非零電壓空間矢量能使電機磁通空間矢量產生運動,而零電壓空間矢量使磁通空間矢量靜止
標簽: foc
上傳時間: 2022-06-30
上傳用戶:qdxqdxqdxqdx
dsp hư ớ ng dẫ n giao tiế p LCD code viế t bằ ng C
上傳時間: 2017-06-17
上傳用戶:xuanjie
hư ớ ng dẫ n về dsp tham khả o các cô ng cụ cơ bả n
上傳時間: 2014-12-01
上傳用戶:zhichenglu
learningMatlab PhÇ n 1 c¬ së Mat lab Ch ¬ ng 1: Cµ i ® Æ t matlab 1.1.Cµ i ® Æ t ch ¬ ng tr×nh: Qui tr×nh cµ i ® Æ t Matlab còng t ¬ ng tù nh viÖ c cµ i ® Æ t c¸ c ch ¬ ng tr×nh phÇ n mÒ m kh¸ c, chØ cÇ n theo c¸ c h íng dÉ n vµ bæ xung thª m c¸ c th« ng sè cho phï hî p. 1.1.1 Khë i ® éng windows. 1.1.2 Do ch ¬ ng tr×nh ® î c cÊ u h×nh theo Autorun nª n khi g¾ n dÜ a CD vµ o æ ® Ü a th× ch ¬ ng tr×nh tù ho¹ t ® éng, cö a sæ
標簽: learningMatlab 172 199 173
上傳時間: 2013-12-20
上傳用戶:lanwei
metricmatlab ch ¬ ng 4 Ma trË n - c¸ c phÐ p to¸ n vÒ ma trË n. 4.1 Kh¸ i niÖ m: - Trong MATLAB d÷ liÖ u ® Ó ® a vµ o xö lý d íi d¹ ng ma trË n. - Ma trË n A cã n hµ ng, m cét ® î c gä i lµ ma trË n cì n m. § î c ký hiÖ u An m - PhÇ n tö aij cñ a ma trË n An m lµ phÇ n tö n» m ë hµ ng thø i, cét j . - Ma trË n ® ¬ n ( sè ® ¬ n lÎ ) lµ ma trË n 1 hµ ng 1 cét. - Ma trË n hµ ng ( 1 m ) sè liÖ u ® î c bè trÝ trª n mét hµ ng. a11 a12 a13 ... a1m - Ma trË n cét ( n 1) sè liÖ u ® î c bè trÝ trª n 1 cét.
標簽: metricmatlab 203 184 tr
上傳時間: 2017-07-29
上傳用戶:來茴
D-sub-jy
標簽: D-sub-jy
上傳時間: 2013-04-15
上傳用戶:eeworm