【正文】
i+j] % 10。}void mult( int a[], int b[]) /*超長(zhǎng)整數(shù)乘法運(yùn)算 */{西安文理學(xué)院計(jì)算機(jī)科學(xué)系 課程設(shè)計(jì)報(bào)告 16 int i, j, c[2*MAX] = {0},d。amp。!h)||ra0amp。amp。 a[i]+=10。 for(i=d。p||ra0) printf()。 /*用 d 紀(jì)錄結(jié)果的最大位數(shù)*/ for(i=0。039。} /*判斷數(shù)組的符號(hào)*/ if(c2[0]==39。 /*輸入兩個(gè)超長(zhǎng)整型數(shù)據(jù)*/ scanf(%s,c2)。最后還要感謝所有軟件工程二班的同學(xué)和老師,是大家共同為整個(gè)集體創(chuàng)造了積極進(jìn)取、奮發(fā)向上的實(shí)習(xí)環(huán)境和氛圍,使我們能夠順利完成整個(gè)課程設(shè)計(jì)。 但是此次設(shè)計(jì)也暴露出自己專業(yè)基礎(chǔ)的很多不足之處。 數(shù)據(jù)存儲(chǔ)運(yùn)算范圍當(dāng)所輸入位數(shù)在 101 范圍以內(nèi)的整數(shù)時(shí),無(wú)論正負(fù),程序都會(huì)給出正確的運(yùn)算結(jié)果當(dāng)所輸入的數(shù)據(jù)位數(shù)超過(guò) 101 時(shí),程序?qū)?huì)停止運(yùn)行。 w[i]==39。 isub(x, v, x)。strcpy(x, )。}if (Compare(u, v) == 0)//被除數(shù)等于除數(shù){ strcpy(w, 1)。 }lu。\039。 }}while (cD[i1] == 0) i。 ilS。//用來(lái)存儲(chǔ)減數(shù)的整型數(shù)組int cD[MAX] = {0}。) lA。 /*判斷最后結(jié)果的位數(shù)*/ if(ra*rb0) printf()。 /*用 d 紀(jì)錄結(jié)果的最大位數(shù) */ for(i = 0。amp。(rb0amp。 /*判斷最后結(jié)果的位數(shù)*/ if(pamp。 } else /*當(dāng) ab 時(shí)的處理*/ for(i=0。amp。i=0。i++) { c[i]=a[i]+b[i]+c[i]。 ilb。) { lb。 /*la 紀(jì)錄 c1 的位數(shù)*/ lb = strlen( c2 )。 //isub()為一個(gè)自定義的整數(shù)減法函數(shù) } w[k++] = s + 39。 //先使余數(shù)的值為空f(shuō)or (i=0,k=0。id。 i la。具體算法為: for(i=0。 ilb。 /*輸入兩個(gè)超長(zhǎng)整型數(shù)據(jù)*/ scanf(%s,c2)。例如,求兩個(gè) 100 位的數(shù)的和。(4)使用 C 或 VB 編寫程序。用數(shù)組對(duì)超長(zhǎng)整數(shù)進(jìn)行存儲(chǔ).其優(yōu)點(diǎn)是進(jìn)行運(yùn)算的時(shí)候比較方便。關(guān)鍵詞:超長(zhǎng)整數(shù);字符串;數(shù)組AbstractOne of the important functions of puter is scientific puting, in scientific research and engineering calculation. Often encountered some big integer calculation problem, the calculation of integers without method using mon microputers directly by the integer programming language is existing types of storage and calculation, this research work to bring a barrier. So long integer solutions for the storage and operation, I put forward its own design solutions, using string array of long integers, store, the processing with numerical instead, because the string string length, and not just in each character strings can be one of the corresponding ultralong integer number, the long integers, add, subtract, multiply and divide into a string of add, subtract, multiply and divide. Use of long integer array stores. The advantages of puting is easier.After the design, this paper realized the long integer data storage and operation procedures, and analyses the testing system, various performance can achieve the desired level. Based on this program at the end of the detailed presentation.Keywords: long integer;string;array西安文理學(xué)院計(jì)算機(jī)科學(xué)系 課程設(shè)計(jì)報(bào)告目錄第一章 緒論 .................................................................................................................................................1 課題背景 ......................................................................................................................................................1 課題簡(jiǎn)介 ......................................................................................................................................................1 編寫目的 ......................................................................................................................................................1 課程意義 ......................................................................................................................................................1第二章 設(shè)計(jì)簡(jiǎn)介及設(shè)計(jì)方案論述 ...............................................................................................2 程序分析 ......................................................................................................................................................2 程序設(shè)計(jì) ......................................................................................................................................................2 數(shù)據(jù)的接收與存儲(chǔ) .............................................................................................................................2 計(jì)算結(jié)果位數(shù)的確定 ........................................................................................................................2 進(jìn)位處理和借位