freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

山東科技大學oj部分題目記答案(文件)

2025-07-11 21:22 上一頁面

下一頁面
 

【正文】 值。 return x。y,amp。}Problem B: 編寫函數(shù)myFloor和myCeil(編程題)取整函數(shù)有四個,分別是 fix, floor, ceil, round。其中myFloor函數(shù)的結(jié)果是不大于data的最大整數(shù),myCeil函數(shù)的結(jié)果是不小于data的最小整數(shù)。每行先輸出floor函數(shù)的結(jié)果,再輸出ceil函數(shù)的結(jié)果。 if(data0) for(i=0。 } else for(i=0。 } return i。amp。amp。 while (scanf(%lf,amp。其中str[]表示待求長度的字符串,返回值是str[]的長度。Output輸出為多行,每行對應(yīng)于一個測試用例。str[i]!=39。}int main(){ int i,N。 getchar()。i=N。}Problem D: 編寫函數(shù)gcd()和lcm()Description輾轉(zhuǎn)相除法,也稱歐幾里得算法,是求最大公約數(shù)的算法。例如,252和105的最大公約數(shù)是21(252 = 21 12;105 = 21 5);因為252 ? 105 = 147,所以147和105的最大公約數(shù)也是21。 147 = 7 21 + 0.此時,余數(shù)是0,所以1071和462的最大公約數(shù)是21。lcm()的返回值是兩個參數(shù)的最小公倍數(shù),函數(shù)原型如下:int lcm(int, int)。Output每行輸出一對a,b的最大公約數(shù)和最小公倍數(shù),順序與輸入對應(yīng)。因此,做題時:1. 首先,作為你程序最后一部分,在這部分之前編寫程序并進行測試;2. 提交,只提交你自己編寫的那一部分程序;否則,這樣提交OJ測試的程序和你自己編寫的程序是不一樣的,往往會出現(xiàn)main()函數(shù)重復定義的編譯錯誤。amp。b==0) return a。 } m=a*b。 c=a%b。amp。b==0) return b。 } m=a*b。 c=a%b。 freopen(, w, stdout)。 return 0。Output兩個較小的整數(shù)a,b,用空格分開。 *p2=temp。 scanf(%d%d, amp。a, amp。注意:a和b相等時不產(chǎn)生交換。}int main(){ int a, b。 if(is_swapped(amp。}Problem C: 編寫函數(shù)unionSet(編程題)Description編寫一個函數(shù)unionSet,對2個集合求并集。Input輸入為2行,每行是一個集合,每行的輸入以數(shù)值0作為結(jié)束,個數(shù)不超過100個。見樣例。i++) {k=0。 } if(k==numA) { m++。 numA=numB=0。 scanf(%d,amp。 while (setB[numB]!=0) { numB++。 printf(%d,setA[0])。 return 0。//專業(yè) 其中students[]是由num個STU類型的結(jié)構(gòu)體組成的數(shù)組。第一行N0表示有N個學生的信息。注意:主函數(shù)已經(jīng)給出,提交時需提交以下內(nèi)容:上述結(jié)構(gòu)體STU的定義(直接復制上就可以,要放在頭文件包含命令之后)、必要的頭文件包含命令以及printInfo函數(shù)的代碼。//3門課程的成績} STU。 char name[50]。 inumA。setB[numB])。 } scanf(%d,amp。setA[numA])。 } } return numA+m。jnumA。 for(i=0。Output輸出2個集合求并后的結(jié)果,兩兩之間用一個空格隔開。其中setA和setB是兩個待合并的集合,numA和numB分別是2個集合的元素個數(shù)。b)) printf(%d %d YES, b, a)。a, amp。Output輸出有兩種情況:1) “a b NO”, 當a,b沒有交換過2) “b a YES”, 當a,b交換過Sample Input5 3Sample Output3 5 YESAppend Code, include int is_swapped(int *p1,int *p2){ if(*p1*p2) return 1。 else printf(%d %d NO, a, b)。b)。 } else return 0。 if(*p1*p2) { temp=*p1。注意:a和b相等時不產(chǎn)生交換。a, amp。}}int main(){ int a, b。 while(c!=0) { a=b。 a=b。 else if(a!=0amp。}}int lcm(int a,int b){ int t,m,n,c。 while(c!=0) { a=b。 a=b。 else if(a!=0amp。Append Code, include int gcd(int a,int b){ int t,m,n,c。因此0是任意整數(shù)的倍數(shù),但是0不能是約數(shù)Sample Input1 12 32 23 24 67 512 618 924 36Sample Output1 11 62 21 62 121 356 129 1812 72HINTInput輸入為多行,每行有一對非負整數(shù)a,b,且a*b不會超出int類型的數(shù)據(jù)范圍。gcd()的返回值是兩個參數(shù)的最大公約數(shù),函數(shù)原型如下:int gcd(int, int)。 1071 = 2 462 + 147.然后從462中不斷減去147直到小于147(可以減3次,即q1 = 3),余數(shù)是21:這時,所剩下的還沒有變成零的數(shù)就是兩數(shù)的最大公約數(shù)。兩個整數(shù)的最大公約數(shù)(亦稱公約數(shù))是能夠同時整除它們的最大的正整數(shù)。 printf(\ncase %d:length=%d.,i,strlen(str))。 printf(case 1:length=%d.,strlen(str))。 scanf(%d,amp。i++)。Sample Input4I love China!Do you want to pass this examination?You will succeed finially!Wish you succeed!Sample Outputcase 1:length=13.case 2:length=37.case 3:length=26.case 4:length=17.HINTAppend Code, include int strlen(char str[]){ int i。Input輸入為多行。 } return 0。 } return i。 } else for(i=0。 if(data0) for(i=0。amp。amp。取整之后的結(jié)果不超出int類型的表示范圍。Input輸入有多行,每行是一個需要轉(zhuǎn)換的實數(shù)。int printf(%d,maxValue(x,y,z))。 scanf(%d%d%d,amp。 x=ab?a:b。其中a、b、c是參與比較的三個整數(shù),返回值是三個數(shù)的最大值。 else printf (%d ,a[j][i])。in。jn。n)。 for(d=0。include int main(){ int i,j,c,d,m,n。Output輸出為多組,每組輸出A的轉(zhuǎn)置矩陣AT。 }}Problem D: Matrix Problem : Array PraticeDescription求一個mn階矩陣A的轉(zhuǎn)置矩陣AT。iceil(j/)。\039。include includeincludeint main(){ int i,j,k。Output當一個串中的字母和數(shù)字部分能夠構(gòu)成一個回文,即輸出“Yes.”;否則輸出“No.”。接下來,你要編寫一個程序來判斷一個串是不是回文。 s[i][n+1]=39。j++)。strcmp(s[i1]+j,END)!=0。Sample Input abcdefg 12345678XYZabc 123 END Sample Outputabcdefg12345678XYZabc 123ENDHINT,若一個字符為空白符之一則返回真。你的任務(wù)是讀入每行字符串,去掉行首和行尾的連續(xù)空白符,但是在任意非空白符中間的空白符不要去除。\f39。\n39。\t39。 for(j=i1。Append Codeinclude include int main(){ int i,j。 39。\n39。輸入最少為一個字符,最多不會超過100個字符。b++) if(b==n1) printf(%d,a[b])。a[n]=k。 if(j=0) for(n=0。i,amp。Sample Inputstart = 1, step = 2, end = 200Sample Output1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199HINT根據(jù)start和step的大小關(guān)系,判斷序列終止的條件可能不同。其中,start為初始數(shù),step為公差,end為終止條件。n++) { if(n==k1) printf(%d,a[n])。nk。i,amp。Sample Inputstart = 1, step = 2, times = 100Sample Output1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199HINTAppend Codeinclude int main(){ int i,j,k,n。Input輸入為一行,格式見sample。 for(k=0。 for(k=0。i=45。Sample Input61 2 3 4 5 10Sample Output1235889HINT當n較大時,菲波那契序列的第n項值和計算量都是很大的,可以先計算出菲波那契序列并用數(shù)組存儲下來,然后查詢出每月兔子數(shù),避免重復運算。 }}Problem B: 兔子的繁殖問題Description假設(shè)一對兔子每月能生一對小兔(一雌一雄),每對小兔出生后的下一個月是沒有繁殖能力的,至出生后的第三個月開始又可以每月生一隊小兔,問從一對剛出生的小兔開始,經(jīng)過若干個月后一共有多少兔子(假設(shè)在此過程中兔子沒有死亡)?這個問題是
點擊復制文檔內(nèi)容
規(guī)章制度相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1