//建立頂級窗口 toplevel = XtVaAppInitialize[&app, "Scroll", NULL, 0, &argc, argv, NULL, NULL] //建立SpinBox n = 0 XtSetArg[args[n], XmNwidth, 400 ] n++ XtSetArg[args[n], XmNheight, 100 ] n++ //XtSetArg[args[n], XmNarrowLayout, XmARROWS_FLAT_END] n++ XtSetArg[args[n], XmNrepeatDelay, 0] n++ //XtSetArg[args[n], XmNarrowOrientation, XmHORIZONTAL] n++ spinbox = XmCreateSpinBox[toplevel, "SpinBox", args, n] XtManageChild[spinbox] XtAddCallback [spinbox, XmNvalueChangedCallback, [XtCallbackProc]ValueChanged, [XtPointer]NULL] XtAddCallback [spinbox, XmNmodifyVerifyCallback, [XtCallbackProc]ModifyVerify, [XtPointer]NULL]
標簽: NULL XtVaAppInitialize toplevel Scroll
上傳時間: 2013-12-26
上傳用戶:fxf126@126.com
此程序改自算法課的一個作業(yè),用四種不同的算法,對隨機生成的n個數(shù)排序(n取值500至5000),并重復(fù)n遍,最后統(tǒng)計平均比較次數(shù)。本在xp下用vc6編寫,現(xiàn)在修改為Ubuntu下gcc編譯。 sortArchieve.c內(nèi)為各個排序算法的實現(xiàn)
上傳時間: 2014-01-22
上傳用戶:linlin
雜波的一個MATLAB仿真,雜波的產(chǎn)生:先生成一個(0,1)分布的隨機數(shù)r,讓后根據(jù)poission分布產(chǎn)生雜波的個數(shù)n,這n個雜波是服從均勻分布
上傳時間: 2013-12-20
上傳用戶:Pzj
關(guān)于制造回文 描述 回文,亦稱回環(huán),是正讀反讀都能讀通的句子,亦有將文字排列成圓圈者,是一種修辭方式和文字游戲。回文運用得當,可以表現(xiàn)兩種事物或現(xiàn)象相互依靠或排斥的關(guān)系。總有人以為回文是英文的專利,其實不然,中文中也有很多回文的例子,譬如: 鶯啼岸柳弄春晴, 柳弄春晴夜月明。 明月夜晴春弄柳, 晴春弄柳岸啼鶯。 看著很有意思,可要想寫出回文,并不是一件很容易的事情。如果有一個字符串,怎樣才能插入最少的內(nèi)容,把它變成回文呢? 例如,要想把字符串 "Zb3bd" 變成回文,就需要插入兩個字符,變成 "dZb3bZd" 或者 "Zdb3bdZ",插入一個字符,是肯定不行的。 輸入 輸入的第一行是字符串的長度 N,3 <= N <= 5000,第二行是一個長度為 N 的字符串。該字符串由英文大小寫字母和數(shù)字組成,英文大寫字母和小寫字母是不同的。 輸出 程序輸出要把該字符串變成回文,需要插入的最少字符數(shù)。
標簽: 制造
上傳時間: 2014-01-24
上傳用戶:gundamwzc
RSA ( Rivest Shamir Adleman )is crypthograph system that used to give a secret information and digital signature . Its security based on Integer Factorization Problem (IFP). RSA uses an asymetric key. RSA was created by Rivest, Shamir, and Adleman in 1977. Every user have a pair of key, public key and private key. Public key (e) . You may choose any number for e with these requirements, 1< e <Æ (n), where Æ (n)= (p-1) (q-1) ( p and q are first-rate), gcd (e,Æ (n))=1 (gcd= greatest common divisor). Private key (d). d=(1/e) mod(Æ (n)) Encyption (C) . C=Mª mod(n), a = e (public key), n=pq Descryption (D) . D=C° mod(n), o = d (private key
標簽: crypthograph information Adleman Rivest
上傳時間: 2017-09-01
上傳用戶:chfanjiang
本程序引入了連通性狀態(tài)壓縮動態(tài)規(guī)劃方法,可以在非常快的時間內(nèi)解決棋盤上的哈密頓回路個數(shù)的計數(shù)。 時間復(fù)雜度O(n*m*3^n)遠低于搜索。
標簽: 程序 狀態(tài) 動態(tài)規(guī)劃 連通性
上傳時間: 2014-01-19
上傳用戶:refent
Use the fast Fourier transform function fft to analyse following signal. Plot the original signal, and the magnitude of its spectrum linearly and logarithmically. Apply Hamming window to reduce the leakage. . The hamming window can be coded in Matlab as for n=1:N hamming(n)=0.54+0.46*cos((2*n-N+1)*pi/N); end; where N is the data length in the FFT.
標簽: matlab fft
上傳時間: 2015-11-23
上傳用戶:石灰?guī)r123
實驗源代碼 //Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關(guān)系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關(guān)系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請輸入矩陣的行數(shù) i: "); scanf("%d",&k); 四川大學(xué)實驗報告 printf("請輸入矩陣的列數(shù) j: "); scanf("%d",&n); warshall(k,n); }
上傳時間: 2016-06-27
上傳用戶:梁雪文以
“Huffman-樹”不僅能對文本數(shù)據(jù)進行編碼、譯碼,提高文本數(shù)據(jù)的傳輸效率,同時它也能對多媒體數(shù)據(jù)(如:數(shù)字圖像、視頻等)進行編碼、譯碼,從而實現(xiàn)多媒體數(shù)據(jù)的壓縮存儲。目前,在Web互聯(lián)網(wǎng)上廣泛使用的JPEG圖像格式就采用了Huffman編碼,與其他圖像格式(如:BMP、TIF等)相比,同一副圖像采用JPEG格式時所需的存儲空間是最少的。在這個實驗中,請設(shè)計一個Huffman編/譯碼器,并模擬數(shù)字圖像的壓縮存儲(編碼)和解碼顯示(譯碼)的過程。 (1)構(gòu)造“Huffman-樹”: ①讀入一個大小為N*M(N為圖像的高度,M為圖像的寬度)的灰度圖像塊,該圖像中的每個像素(元素)的取值范圍是0~255,取值為0表示該像素是“黑色”,取值為255表示該像素是“白色”,其他取值表示介于“黑色”和“白色”之間的灰度值。 ②統(tǒng)計讀入圖像塊中每種灰度值出現(xiàn)的次數(shù),并去除出現(xiàn)次數(shù)為零的灰度值,以此作為構(gòu)造“Huffman-樹”所需的權(quán)值。 ③說明:在構(gòu)造“Huffman-樹”的過程中,當有多個待合并元素的權(quán)值相同時,每次選擇灰度值較小的兩個元素進行合并。 (2)Huffman編碼(壓縮存儲):讀入新的灰度圖像塊,利用已建立好的“Huffman-樹”對其進行編碼,將圖像的寬度、高度信息和編碼結(jié)果保存到文件(如:compress_image.txt)中,同時計算Huffman編碼的壓縮比并輸出。壓縮比的計算公式如下:壓縮比=原始圖像所需比特數(shù)/壓縮后圖像所需比特數(shù)。 (3)Huffman譯碼(解碼顯示):讀入壓縮存儲的灰度圖像,利用已建立好的“Huffman-樹”對其進行譯碼,將譯碼結(jié)果按照原有寬度、高度還原圖像,并將還原之后的圖像保存到文件(如:decoding_image.txt)中。
標簽: 樹
上傳時間: 2016-12-02
上傳用戶:592595
#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; /*分數(shù)*/ int range; /**/ int item; /*項目*/ }ATH; typedef struct schoolstruct /*學(xué)校*/ { int count; /*編號*/ int serial; /**/ int menscore; /*男選手分數(shù)*/ int womenscore; /*女選手分數(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輸入運動項目序號 (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n這個項目已經(jīng)存在請選擇其他的數(shù)字\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超過學(xué)校數(shù)目,請重新輸入"); 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)?"); 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號學(xué)校的結(jié)果成績:",pfirst->serial); printf("\n\n項目的數(shù)目\t學(xué)校的名字\t分數(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按任意建 進入下一頁"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n運動會結(jié)果:\n\n學(xué)校編號\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按任意建結(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 運動會分數(shù)統(tǒng)計\n"); printf("輸入學(xué)校數(shù)目 (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
蟲蟲下載站版權(quán)所有 京ICP備2021023401號-1