#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*運(yùn)動(dòng)員*/ { char name[20]; int score; /*分?jǐn)?shù)*/ int range; /**/ int item; /*項(xiàng)目*/ }ATH; typedef struct schoolstruct /*學(xué)校*/ { int count; /*編號(hào)*/ int serial; /**/ int menscore; /*男選手分?jǐn)?shù)*/ int womenscore; /*女選手分?jǐn)?shù)*/ 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輸入運(yùn)動(dòng)項(xiàng)目序號(hào) (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n這個(gè)項(xiàng)目已經(jīng)存在請(qǐng)選擇其他的數(shù)字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { printf("\n項(xiàng)目不存在"); printf("\n請(qǐng)重新輸入"); 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輸入序號(hào) of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { printf("\n超過(guò)學(xué)校數(shù)目,請(qǐng)重新輸入"); 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繼續(xù)輸入運(yùn)動(dòng)項(xiàng)目(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號(hào)學(xué)校的結(jié)果成績(jī):",pfirst->serial); printf("\n\n項(xiàng)目的數(shù)目\t學(xué)校的名字\t分?jǐn)?shù)"); 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按任意建 進(jìn)入下一頁(yè)"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n運(yùn)動(dòng)會(huì)結(jié)果:\n\n學(xué)校編號(hào)\t男運(yùn)動(dòng)員成績(jī)\t女運(yùn)動(dòng)員成績(jī)\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按任意建結(jié)束"); 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("文件已經(jīng)成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 運(yùn)動(dòng)會(huì)分?jǐn)?shù)統(tǒng)計(jì)\n"); printf("輸入學(xué)校數(shù)目 (x>= 5):"); scanf("%d",&nsc); printf("輸入男選手的項(xiàng)目(x<=20):"); scanf("%d",&msp); printf("輸入女選手項(xiàng)目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
標(biāo)簽: 源代碼
上傳時(shí)間: 2016-12-28
上傳用戶:150501
function [alpha,N,U]=youxianchafen2(r1,r2,up,under,num,deta) %[alpha,N,U]=youxianchafen2(a,r1,r2,up,under,num,deta) %該函數(shù)用有限差分法求解有兩種介質(zhì)的正方形區(qū)域的二維拉普拉斯方程的數(shù)值解 %函數(shù)返回迭代因子、迭代次數(shù)以及迭代完成后所求區(qū)域內(nèi)網(wǎng)格節(jié)點(diǎn)處的值 %a為正方形求解區(qū)域的邊長(zhǎng) %r1,r2分別表示兩種介質(zhì)的電導(dǎo)率 %up,under分別為上下邊界值 %num表示將區(qū)域每邊的網(wǎng)格剖分個(gè)數(shù) %deta為迭代過(guò)程中所允許的相對(duì)誤差限 n=num+1; %每邊節(jié)點(diǎn)數(shù) U(n,n)=0; %節(jié)點(diǎn)處數(shù)值矩陣 N=0; %迭代次數(shù)初值 alpha=2/(1+sin(pi/num));%超松弛迭代因子 k=r1/r2; %兩介質(zhì)電導(dǎo)率之比 U(1,1:n)=up; %求解區(qū)域上邊界第一類邊界條件 U(n,1:n)=under; %求解區(qū)域下邊界第一類邊界條件 U(2:num,1)=0;U(2:num,n)=0; for i=2:num U(i,2:num)=up-(up-under)/num*(i-1);%采用線性賦值對(duì)上下邊界之間的節(jié)點(diǎn)賦迭代初值 end G=1; while G>0 %迭代條件:不滿足相對(duì)誤差限要求的節(jié)點(diǎn)數(shù)目G不為零 Un=U; %完成第n次迭代后所有節(jié)點(diǎn)處的值 G=0; %每完成一次迭代將不滿足相對(duì)誤差限要求的節(jié)點(diǎn)數(shù)目歸零 for j=1:n for i=2:num U1=U(i,j); %第n次迭代時(shí)網(wǎng)格節(jié)點(diǎn)處的值 if j==1 %第n+1次迭代左邊界第二類邊界條件 U(i,j)=1/4*(2*U(i,j+1)+U(i-1,j)+U(i+1,j)); end if (j>1)&&(j U2=1/4*(U(i,j+1)+ U(i-1,j)+ U(i,j-1)+ U(i+1,j)); U(i,j)=U1+alpha*(U2-U1); %引入超松弛迭代因子后的網(wǎng)格節(jié)點(diǎn)處的值 end if i==n+1-j %第n+1次迭代兩介質(zhì)分界面(與網(wǎng)格對(duì)角線重合)第二類邊界條件 U(i,j)=1/4*(2/(1+k)*(U(i,j+1)+U(i+1,j))+2*k/(1+k)*(U(i-1,j)+U(i,j-1))); end if j==n %第n+1次迭代右邊界第二類邊界條件 U(i,n)=1/4*(2*U(i,j-1)+U(i-1,j)+U(i+1,j)); end end end N=N+1 %顯示迭代次數(shù) Un1=U; %完成第n+1次迭代后所有節(jié)點(diǎn)處的值 err=abs((Un1-Un)./Un1);%第n+1次迭代與第n次迭代所有節(jié)點(diǎn)值的相對(duì)誤差 err(1,1:n)=0; %上邊界節(jié)點(diǎn)相對(duì)誤差置零 err(n,1:n)=0; %下邊界節(jié)點(diǎn)相對(duì)誤差置零 G=sum(sum(err>deta))%顯示每次迭代后不滿足相對(duì)誤差限要求的節(jié)點(diǎn)數(shù)目G end
標(biāo)簽: 有限差分
上傳時(shí)間: 2018-07-13
上傳用戶:Kemin
#include <stdio.h> #include <stdlib.h> #define SMAX 100 typedef struct SPNode { int i,j,v; }SPNode; struct sparmatrix { int rows,cols,terms; SPNode data [SMAX]; }; sparmatrix CreateSparmatrix() { sparmatrix A; printf("\n\t\t請(qǐng)輸入稀疏矩陣的行數(shù),列數(shù)和非零元素個(gè)數(shù)(用逗號(hào)隔開):"); scanf("%d,%d,%d",&A.cols,&A.terms); for(int n=0;n<=A.terms-1;n++) { printf("\n\t\t輸入非零元素值(格式:行號(hào),列號(hào),值):"); scanf("%d,%d,%d",&A.data[n].i,&A.data[n].j,&A.data[n].v); } return A; } void ShowSparmatrix(sparmatrix A) { int k; printf("\n\t\t"); for(int x=0;x<=A.rows-1;x++) { for(int y=0;y<=A.cols-1;y++) { k=0; for(int n=0;n<=A.terms-1;n++) { if((A.data[n].i-1==x)&&(A.data[n].j-1==y)) { printf("%8d",A.data[n].v); k=1; } } if(k==0) printf("%8d",k); } printf("\n\t\t"); } } void sumsparmatrix(sparmatrix A) { SPNode *p; p=(SPNode*)malloc(sizeof(SPNode)); p->v=0; int k; k=0; printf("\n\t\t"); for(int x=0;x<=A.rows-1;x++) { for(int y=0;y<=A.cols-1;y++) { for(int n=0;n<=A.terms;n++) { if((A.data[n].i==x)&&(A.data[n].j==y)&&(x==y)) { p->v=p->v+A.data[n].v; k=1; } } } printf("\n\t\t"); } if(k==1) printf("\n\t\t對(duì)角線元素的和::%d\n",p->v); else printf("\n\t\t對(duì)角線元素的和為::0"); } int main() { int ch=1,choice; struct sparmatrix A; A.terms=0; while(ch) { printf("\n"); printf("\n\t\t 稀疏矩陣的三元組系統(tǒng) "); printf("\n\t\t*********************************"); printf("\n\t\t 1------------創(chuàng)建 "); printf("\n\t\t 2------------顯示 "); printf("\n\t\t 3------------求對(duì)角線元素和"); printf("\n\t\t 4------------返回 "); printf("\n\t\t*********************************"); printf("\n\t\t請(qǐng)選擇菜單號(hào)(0-3):"); scanf("%d",&choice); switch(choice) { case 1: A=CreateSparmatrix(); break; case 2: ShowSparmatrix(A); break; case 3: SumSparmatrix(A); break; default: system("cls"); printf("\n\t\t輸入錯(cuò)誤!請(qǐng)重新輸入!\n"); break; } if (choice==1||choice==2||choice==3) { printf("\n\t\t"); system("pause"); system("cls"); } else system("cls"); } }
上傳時(shí)間: 2020-06-11
上傳用戶:ccccy
IDAQ-8098 控溫模塊是專為精確控溫應(yīng)用而設(shè)計(jì)的,采用多 CPU 方案實(shí)現(xiàn)采集和 PID 控制分開工 作,采用 Modbus 通信協(xié)議,通過(guò) RS-485 通信接口下載控溫參數(shù),并實(shí)時(shí)監(jiān)測(cè)被控溫區(qū)實(shí)時(shí)溫度、控溫 狀態(tài)和數(shù)字量輸入輸出狀態(tài),還可以控制控溫的啟停等功能。啟動(dòng)控溫后,模塊能夠按照設(shè)定的控溫參數(shù) 自動(dòng)工作,無(wú)須其他設(shè)備干預(yù),這樣就大大減輕了控制系統(tǒng)的工作負(fù)擔(dān),提高了整個(gè)系統(tǒng)的穩(wěn)定性和可靠 性。IDAQ-8098 控溫模塊完全實(shí)現(xiàn)系統(tǒng)的溫度采集和控制,有效減少了技術(shù)部門在該功能上的開發(fā)和調(diào)試 時(shí)間,使產(chǎn)品能夠快速占領(lǐng)市場(chǎng)。 ◆ 多 CPU 工作方式,采集熱電偶信號(hào)和 PID 控制完全分開協(xié)同式工作 ◆ 控溫方式:增量 PID 加模糊控制,自適應(yīng) PID 控制(保存自適應(yīng)的最佳參數(shù)供下次使用) ◆ 8 個(gè)控溫通道各自獨(dú)立 PID 控制,對(duì)應(yīng)于 8 個(gè)通道的熱電偶輸入 ◆ PID 采樣周期可達(dá) 500ms ◆ 控溫精度最高能達(dá)到±0.5℃ ◆ 五種脈寬輸出指示五種控溫狀態(tài)(不控溫、加熱、恒溫、預(yù)警和報(bào)警) ◆ 可通過(guò) RS-485 串口遠(yuǎn)程監(jiān)視工作狀態(tài) ◆ 可和 PLC 掛接通訊,組合成最完美最經(jīng)濟(jì)最可靠的 IO 控制和被控溫區(qū)溫度控制系統(tǒng)◆ 有效分辨率:16 位 ◆ 通道:8 路差分 ◆ 輸入類型:輸入類型:熱電偶,PT100,0~20mA,0-10V,-20-+20mV,-78-+78mV,-312-+312mV,0-5000mV ◆ 熱電偶類型與溫度范圍: J -200 ~ 1200℃ K -200 ~ 1370℃ T -200 ~ 400℃ E -200 ~ 1000℃ R -50 ~ 1760℃ S -50 ~ 1760℃ B 0 ~ 1820℃ PT100 溫度范圍:-200 ~ 660℃ ◆ 隔離電壓:3000Vdc ◆ 故障與過(guò)壓保護(hù):最大承受電壓±35V ◆ 采樣速率:20 采樣點(diǎn)/ 秒(總共) ◆ 輸入阻抗:20M ◆ 精度:±0.1%( 電壓輸入) ◆ 零漂移:±3uV/℃
標(biāo)簽: PID溫控模塊
上傳時(shí)間: 2021-12-09
上傳用戶:
主要內(nèi)容介紹 Allegro 如何載入 Netlist,進(jìn)而認(rèn)識(shí)新式轉(zhuǎn)法和舊式轉(zhuǎn)法有何不同及優(yōu)缺點(diǎn)的分析,透過(guò)本章學(xué)習(xí)可以對(duì) Allegro 和 Capture 之間的互動(dòng)關(guān)係,同時(shí)也能體驗(yàn)出 Allegro 和 Capture 同步變更屬性等強(qiáng)大功能。Netlist 是連接線路圖和 Allegro Layout 圖檔的橋樑。在這裏所介紹的 Netlist 資料的轉(zhuǎn)入動(dòng)作只是針對(duì)由 Capture(線路圖部分)產(chǎn)生的 Netlist 轉(zhuǎn)入 Allegro(Layout部分)1. 在 OrCAD Capture 中設(shè)計(jì)好線路圖。2. 然後由 OrCAD Capture 產(chǎn)生 Netlist(annotate 是在進(jìn)行線路圖根據(jù)第五步產(chǎn)生的資料進(jìn)行編改)。 3. 把產(chǎn)生的 Netlist 轉(zhuǎn)入 Allegro(layout 工作系統(tǒng))。 4. 在 Allegro 中進(jìn)行 PCB 的 layout。 5. 把在 Allegro 中產(chǎn)生的 back annotate(Logic)轉(zhuǎn)出(在實(shí)際 layout 時(shí)可能對(duì)原有的 Netlist 有改動(dòng)過(guò)),並轉(zhuǎn)入 OrCAD Capture 裏進(jìn)行回編。
上傳時(shí)間: 2022-04-28
上傳用戶:kingwide
Grid數(shù)據(jù)顯示
標(biāo)簽: Grid
上傳時(shí)間: 2015-01-09
上傳用戶:ikemada
asp.net數(shù)據(jù)庫(kù)程序范例
上傳時(shí)間: 2013-12-23
上傳用戶:wqxstar
動(dòng)態(tài)聚類k-means演算 將輸入在程式中的數(shù)據(jù)資料 給予適當(dāng)?shù)姆秩?/p>
上傳時(shí)間: 2015-03-16
上傳用戶:離殤
清華大學(xué)的數(shù)據(jù)結(jié)構(gòu)講義,經(jīng)典的書籍,照這個(gè)講義複習(xí),一切ok
標(biāo)簽:
上傳時(shí)間: 2015-03-31
上傳用戶:it男一枚
VC odbc 連接Access 數(shù)據(jù)庫(kù) 的例子,比較簡(jiǎn)單
上傳時(shí)間: 2014-01-27
上傳用戶:1051290259
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1