九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOCX文檔下載  

算法標(biāo)準(zhǔn)答案.docx

  • 資源ID:116639603       資源大?。?span id="24d9guoke414" class="font-tahoma">94.02KB        全文頁數(shù):151頁
  • 資源格式: DOCX        下載積分:10積分
快捷下載 游客一鍵下載
會員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要10積分
郵箱/手機(jī):
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機(jī)號,方便查詢和重復(fù)下載(系統(tǒng)自動生成)
支付方式: 支付寶    微信支付   
驗(yàn)證碼:   換一換

 
賬號:
密碼:
驗(yàn)證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會被瀏覽器默認(rèn)打開,此種情況可以點(diǎn)擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標(biāo)題沒有明確說明有答案則都視為沒有答案,請知曉。

算法標(biāo)準(zhǔn)答案.docx

Problem H: 乘法口訣Time Limit: 1 SecMemory Limit: 64 MBSubmit: 11234Solved: 3034Description還記得以前小學(xué)時的九九乘法口訣吧?,F(xiàn)在要求你編寫程序打印出乘法口訣。 不過現(xiàn)在的乘法口訣表跟以前稍微有點(diǎn)區(qū)別,我告訴你一個數(shù)字n( 1 = n = 9),你要給我打出相應(yīng)的nn乘法口訣表。Input多個測試數(shù)據(jù)。每個測試數(shù)據(jù)一行,輸入整數(shù)n.Output輸出nn乘法口訣表。 每個乘法口訣表中的任何一個乘式占6列,不足6列的在后面補(bǔ)空格。同一行2個乘式之間有一個空格。 兩個乘法口訣表之間有一個空行。注意乘法口訣中每一行最后沒有空格,如4*4=16和5*5=25后面都沒有空格的。Sample Input126Sample Output1*1=11*1=11*2=2 2*2=41*1=1 1*2=2 2*2=41*3=3 2*3=6 3*3=91*4=4 2*4=8 3*4=12 4*4=161*5=5 2*5=10 3*5=15 4*5=20 5*5=251*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36HINT%-2d表示對齊方式為左對齊例如,printf(%-6d,100);將輸出: 100#include#includeint main()int n,i,j;char a1010;while(scanf(%d,&n)!=EOF)for(i=1;i=n;i+)for(j=1;j=i-1;j+)aij=j*i;printf(%d*%d=%-2d ,j,i,aij);printf(%d*%d=%-2d,i,i,i*i);printf(n);printf(n);return 0;Problem G: 打印金字塔Time Limit: 1 SecMemory Limit: 64 MBSubmit: 6241Solved: 3777Description請編寫程序輸出金字塔圖形。Input多個測試數(shù)據(jù)。每個測試數(shù)據(jù)輸入一個整數(shù)n(1 = n = 9)Output輸出n層金字塔。Sample Input13Sample Output* * *HINT用雙重循環(huán)做,外循環(huán)代表行數(shù),第一個內(nèi)循環(huán)輸出空格,第二個內(nèi)循環(huán)輸出*for(;)for(;)/輸出空格for(;)/輸出*/外循環(huán)#includeint main() int n,i,j,k;while(scanf(%d,&n)!=EOF)for(i=1;i=n;i+)for(j=1;j=n-i;j+) printf( );for(k=1;k2*i;k+) printf(*); printf(n) ; return 0;3920: 老外買瓷磚Time Limit: 1 SecMemory Limit: 64 MBSubmit: 1344Solved: 656Description大酬賓活動的第三天,店里突然來了一個老外。還是高中生的小娥在開店??蓱z的小娥被老外流暢的外語給嚇蒙了。老外沒辦法,只好一個字母一個字母地把訂單念給小娥。嚇蒙的小娥只記得有幾個元音字母了(aeiou),不過很不幸的是她把H也當(dāng)作了A,Y當(dāng)作了I.Input第一行輸入一個整數(shù)n,表示老外說了多少句話。然后是n行,每一行是老外說的外語。Output對于老外說的每句話,請統(tǒng)計(jì)出小娥記得的各元音字母的個數(shù)(包含記錯的),每個元音1行,格式見例子Sample Input2Hello.How are you!Sample Outputa:1e:1i:0o:1u:0a:2e:1i:1o:2u:1HINT一句話不超過50個字符#include void f(int* a,char* s) while(*s) switch(*s) case h: case H: case A: case a:a0+; break; case E: case e: a1+;break; case Y: case y: case I: case i: a2+; break; case O: case o: a3+; break; case U: case u: a4+;break; s+; int main() char s200; int a5; int n,i,j; scanf(%d,&n); getchar(); for(i=0;in;i+) for(j=0;j5;j+) aj=0; gets(s); f(a,s); printf(a:%dne:%dni:%dno:%dnu:%dn,a0,a1,a2,a3,a4); return 0; Problem A: 雙層金字塔Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4962Solved: 3290Description輸出雙層金字塔。Input多個測試數(shù)據(jù)。每個測試數(shù)據(jù)輸入一個整數(shù)n( 2 = n = 9) Output輸出雙層金字塔。Sample Input25Sample Output * * * * * * * * * *#include int main() int n,i,j,a,b; while(scanf(%d,&n)!=EOF) for(i=1;i=n;i+) for(j=1;j=n-i;j+) printf( ); for(j=1;j=2*i-1;j+) printf(*); printf(n); for(a=1;an;a+) for(b=1;b=a;b+) printf( ); for(b=1;b=2*(n-a)-1;b+) printf(*); printf(n); return 0; 3919: 堆瓷磚Time Limit: 1 SecMemory Limit: 64 MBSubmit: 1819Solved: 750Description上次來定制的客戶買走了不少瓷磚,確實(shí)給公司帶來了不少利潤,可是望著裁剪下來的瓷磚,陳蓋歷發(fā)愁了。這些尺寸不一的瓷磚堆的滿地都是。哎,還是想個辦法把他們堆成堆吧。當(dāng)然堆的時候最大的要放在下面,絕對不允許大的瓷磚放在小的上面,否則變形了下次就不好賣了。你能幫忙把這些瓷磚堆起來嗎?Input第一行輸入一個整數(shù)n,表示共要堆成的堆數(shù)。然后是n行,每行先輸入1個整數(shù)m,表示這一堆有m塊瓷磚,然后緊跟著輸入m個整數(shù),表示瓷磚的尺寸Output對于每一堆輸出一行,分別是該堆的瓷磚尺寸,按照從大到小進(jìn)行排列,2個數(shù)之間有一個空格Sample Input24 3 4 5 63 8 4 9Sample Output6 5 4 39 8 4HINTn m 不會超過5012345678910111213141516171819202122232425262728293031323334#include int main() int n,i,j,l,a50,index,t,k; scanf(%d,&n); for(k=0;kn;k+) scanf(%d,&l); for(j=0;jl;j+) scanf(%d,&aj); for(j=0;jl;j+) index=j; for(i=j+1;il;i+) if(aindexai) index=i; t=aindex; aindex=aj; aj=t; for(j=0;jl-1;j+) printf(%d ,aj); printf(%dn,al-1); return 0; 3918: 定制瓷磚Time Limit: 1 SecMemory Limit: 64 MBSubmit: 1746Solved: 1092Description新年大酬賓活動一開展,吸引了好多客戶。這天來了一個客戶,他有一個特別的要求。他需要定制不同尺寸的瓷磚,用來裝修在杭州、臨安等地買的10幾套房子。他的要求是這樣的,他報(bào)出房間的長與寬(當(dāng)然都是整數(shù)),然后你按照他的要求給他一個瓷磚的尺寸(正方形的,也是整數(shù)),以該尺寸的瓷磚能正好鋪滿他要求的房間。當(dāng)然他希望瓷磚的數(shù)量越少越好。ACM出身的陳蓋歷嘿嘿一笑,不就是求最大公約數(shù)嗎?當(dāng)然程序還是要你來寫的。Input第一行輸入一個整數(shù)n,表示客戶的房間數(shù)。然后是n行,每行輸入2個整數(shù),分別表示房間的長與寬Output對于每組數(shù)據(jù),輸出一個整數(shù),表示瓷磚的邊長Sample Input26 126 8Sample Output62#include int main() int n,i,a,b,t,j,m; scanf(%d,&n); for(i=1;ib) t=a;a=b;b=t; for(j=a;j=2;j-) if(a%j=0&b%j=0) break; m=j; printf(%dn,j); return 0; 4135: 新年掛燈籠Time Limit: 1 SecMemory Limit: 128 MBSubmit: 1025Solved: 525Description又是新的一年,家家戶戶掛燈籠。請你編寫一個程序,能根據(jù)需要打印出燈籠的圖案。Input多組測試數(shù)據(jù),先輸入一個整數(shù)t,表示組數(shù),然后輸入然后輸入t行,每行輸入1個整數(shù)n(n不會大于9),代表燈籠上半部分的層數(shù)Output對于每組測試數(shù)據(jù)輸出對應(yīng)的燈籠圖案Sample Input3123Sample Output* * * * * * *#include int main() int n; scanf(%d,&n); for(int i=1;i=n;i+) int x; int j; scanf(%d,&x); for(j=1;j=x;j+) for(int k=1;k=x-j;k+) printf( ); for(int k=0;k1;j-) for(int k=1;kx-j+2;k+) printf( ); for(int k=0;k(x+2*(j-2);k+) printf(*); printf(n); return 0; 4137: 壓歲錢Time Limit: 1 SecMemory Limit: 128 MBSubmit: 1186Solved: 721Description過年了,有些同學(xué)還能收到壓歲錢。真羨慕。你能幫他算下,他收到了多少壓歲錢嗎?Input多組測試數(shù)據(jù),先輸入一個整數(shù)T,表示組數(shù),然后輸入然后輸入t行,每行先輸入1個整數(shù)n表示他收到壓歲錢的次數(shù),后面緊跟著n個整數(shù),表示他每次收到的錢數(shù)Output對于每組測試數(shù)據(jù),請輸出他收到壓歲錢總數(shù)Sample Input23 100 200 3004 100 400 50 600Sample Output6001150#include int main() int n,m,i,t,j,s; scanf(%d,&t); for(i=1;i=t;i+) scanf(%d,&n); s=0; for(j=0;jn;j+) scanf(%d,&m); s=s+m; printf(%dn,s); return 0; 2413: 求三角形面積C語言初學(xué)者百題大戰(zhàn)之十四Time Limit: 1 SecMemory Limit: 64 MBSubmit: 7507Solved: 4152Description輸入三角形的三邊長,求三角形面積。為簡單起見,設(shè)輸入的三邊長a,b,c能構(gòu)成三角形。Input輸入為一行,輸入三角形的三條邊長。Output輸出為一行,計(jì)算出該三角形的面積,精確到小數(shù)點(diǎn)后2位Sample Input3 4 5Sample Output6.00HINT面積可以按下面的公式計(jì)算s=sqrt(p(p-a)(p-b)(p-c)其中p=(a+b+c)/2#include #include int main() float a,b,c,s,p; scanf(%f %f %f,&a,&b,&c); p=(a+b+c)*0.5; s=sqrt(p*(p-a)*(p-b)*(p-c); printf(%.2fn,s); return 0; 2412: 鸚鵡學(xué)舌3C語言初學(xué)者百題大戰(zhàn)之十三Time Limit: 1 SecMemory Limit: 64 MBSubmit: 5169Solved: 2593Description鸚鵡越來越會說話了,你可以說一句話(最多不要超過80個字符哦),鸚鵡也能很快把你的話重復(fù)一遍。Input輸入一行,中間可能有空格,回車表示說完了。Output輸出也為一行,輸出剛才輸入的內(nèi)容。Sample InputI am a student.Sample OutputI am a student.#include #include int main() char a81, * p=a; gets(a); puts(a); 2411: 鸚鵡學(xué)舌2C語言初學(xué)者百題大戰(zhàn)之十二Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4234Solved: 3456Description還記得以前做過的那題鸚鵡學(xué)舌嗎?恩,不錯,那次要求輸入一個整數(shù),然后你要輸出該整數(shù)。現(xiàn)在要求從終端(鍵盤)輸入一個字符,以回車鍵確認(rèn),然后你的程序應(yīng)該能輸出該字符。Input輸入一個字符,以回車確認(rèn)Output輸出你剛才輸入的字符Sample InputeSample Outpute#include int main() char c; c = getchar(); putchar(c); printf(n); return 0; 3549: 更改大小寫Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4089Solved: 2942Description將輸入一行字符串(小于80個字符),將其中的所有小寫字母改為大寫,其他字符不變。Input輸入一行字符串,以回車結(jié)束。Output將字符串中小寫字母改大寫后輸出。Sample InputThere are 3 pens.Sample OutputTHERE ARE 3 PENS.HINT#include #include int main() char s80; int len,i; gets(s); /輸入一段字符 len=strlen(s); /計(jì)算字符串長度 for(i=0;i=a&si=z) /將小寫字母轉(zhuǎn)換為大寫 si=si-32; puts(s); /輸出修改后的字符串 return 0; 3545: 顛倒字符串Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4532Solved: 2539Description輸入一個以回車結(jié)束的字符串(少于80個字符),將字符串的內(nèi)容顛倒過來再輸出Input多組測試數(shù)據(jù),每組輸入一個以回車結(jié)束的字符串(少于80個字符)。Output將這個字符串顛倒過來輸出Sample InputABC XYZMy godSample OutputZYX CBAdog yM#include int main() char c90; int n,i,a; while(c0=getchar()!=EOF) i=1; while(ci=getchar()!=n) i+; for(n=i-1;n=0;n-) printf(%c,cn); putchar(n); return 0; Problem A: 零起點(diǎn)學(xué)算法87打印所有低于平均分的分?jǐn)?shù)Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4813Solved: 1344Description輸入n個成績,打印出所有低于平均分的分?jǐn)?shù)(注意:ave = s/n中s 為float或ave = (float)s/n)。Input多個測試數(shù)據(jù)每個測試數(shù)據(jù)一行,在這行中先輸入分?jǐn)?shù)的個數(shù)n(1=n=100),然后緊跟著輸入n個整數(shù)(代表分?jǐn)?shù))Output對于每個測試數(shù)據(jù),輸出一行按照輸入順序輸出所有低于()平均分的分?jǐn)?shù),中間用一個空格隔開,如果沒有低于平均分的那么只輸出一個空行Sample Input3 40 50 602 90 805 10 10 90 80Sample Output408010 10#include int main() int a,p100,flag=0; while(scanf(%d,&a)!=EOF) int i,sum; double ave; sum=0; for(i=0;ia;i+) scanf(%d,&pi); sum=sum+pi; ave=(float)sum/a; for(i=0;ia;i+) if(piave) if(flag=0) printf(%d,pi); flag=1; else printf( %d,pi); printf(n); flag=0; 2445: 平方和與立方和Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4252Solved: 2145Description給定一段連續(xù)的整數(shù),求出他們中所有偶數(shù)的平方和以及所有奇數(shù)的立方和。Input輸入數(shù)據(jù)包含多組測試實(shí)例,每組測試實(shí)例包含一行,由兩個整數(shù)m和n組成。Output對于每組輸入數(shù)據(jù),輸出一行,應(yīng)包括兩個整數(shù)x和y,分別表示該段連續(xù)的整數(shù)中所有偶數(shù)的平方和以及所有奇數(shù)的立方和。你可以認(rèn)為32位整數(shù)足以保存結(jié)果。Sample Input3 12 5Sample Output4 2820 152#include int main() int a,b,t,i,s,c; while(scanf(%d%d,&a,&b)!=EOF) s=0; c=0; if(ab) t=a; a=b; b=t; for(i=a;i=b;i+) if(i%2=0) s=s+i*i; if(i%2=1) c=c+i*i*i; printf(%d %dn,s,c); return 0; 2444: 求奇數(shù)的乘積Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4692Solved: 3042Description給你n個整數(shù),求他們中所有奇數(shù)的乘積。Input輸入數(shù)據(jù)包含多個測試實(shí)例,每個測試實(shí)例占一行,每行的第一個數(shù)為n,表示本組數(shù)據(jù)一共有n個,接著是n個整數(shù),你可以假設(shè)每組數(shù)據(jù)必定至少存在一個奇數(shù)。Output輸出每組數(shù)中的所有奇數(shù)的乘積,對于測試實(shí)例,輸出一行。Sample Input3 1 2 34 2 3 4 5Sample Output315#include int main() int n,i,s,m; while(scanf(%d,&n)!=EOF) s=1; for(i=1;i=n;i+) scanf(%d,&m); if(m%2=1) s=s*m; printf(%dn,s); return 0; Problem A: 偶數(shù)排序Time Limit: 1 SecMemory Limit: 64 MBSubmit: 1959Solved: 987Description輸入一個正整數(shù)N和N個整數(shù),將它們中的偶數(shù)按從大到小的順序進(jìn)行排序后輸出。 Input多組測試數(shù)據(jù),每組輸入一個正整數(shù)N(1N100)和N個整數(shù),用空格分隔。 Output將這N個數(shù)中的偶數(shù)按從大到小的順序輸出Sample Input10 8 4 14 2 11 30 40 500 17 1008 80 200 99 -12 34 55 88 11Sample Output500 100 40 30 14 8 4 2200 88 80 34 -12#include int main() int i,j,t,n; int a101,b101; while(scanf(%d,&n)!=EOF) for(i=1;i=n;i+) scanf(%d,&ai); for(i=1;i=n;i+) for(j=i;j=n;j+) if(aiaj) t=ai; ai=aj; aj=t; elsecontinue; for(i=1;i=n;i+) if(ai%2=0) if(i!=n) printf(%d ,ai); elseprintf(%dn,ai); Problem B: 零起點(diǎn)學(xué)算法92元素前移1位Time Limit: 1 SecMemory Limit: 64 MBSubmit: 1934Solved: 1231Description將數(shù)組所有元素前移一位(最前面的元素移到最后)然后輸出移動后的數(shù)組Input多組測試數(shù)據(jù),每組第一行輸入一個整數(shù)n(不大于20)第二行輸入n個整數(shù)Output輸出前移一位后的數(shù)組Sample Input41 2 3 4Sample Output2 3 4 1#include int main() int n,m,i,j,k; int a20,b20; while(scanf(%d,&n)!=EOF) for(i=0;in;i+) scanf(%d,&ai); for(i=0;in-1;i+) bi=ai+1; printf(%d ,bi); printf(%dn,a0); return 0; Problem C: 零起點(diǎn)學(xué)算法86FibonaccTime Limit: 1 SecMemory Limit: 64 MBSubmit: 1798Solved: 983DescriptionFibonacci數(shù)列定義為(1,1,2,3,5,8,.),即每個元素是前兩個元素的和。如果一個Fibonacci數(shù)與所有小于它的Fibonacci數(shù)互質(zhì),那么稱之為Fibonacci質(zhì)數(shù)?,F(xiàn)在要求你輸出前n個Fibonacci數(shù) The Fibonacci Numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 . are defined by the recurrence: F(0)=0 F(1)=1 F(i)=F(i-1)+F(i-2) Write a program to calculate the Fibonacci Numbers. InputThe first line of the input file contains a single integer T, the number of test cases. The following T lines,each contains an integer n ( 0 = n = 45 ), and you are expected to calculate Fn.OutputOutput Fn on a separate line.Sample Input5035920Sample Output025346765#include int f(int n); main() int t,i; int n,c50; scanf(%d,&t); for(i=0;it;i+) scanf(%d,&ci); for(i=0;it;i+) n=ci; f(n); int f(int n) int i,f1=1,f2=1,f3; if(n=0) printf(0n); else if(n=1|n=2) printf(1n); else for(i=0;in-2;i+) f3=f1+f2; f2=f1; f1=f3; printf(%dn,f1); 3542: 插入一個數(shù)到數(shù)列中Time Limit: 1 SecMemory Limit: 64 MBSubmit: 3257Solved: 1671Description已有一個排序好的數(shù)列:0 10 20 30 40 50 60 70 80,輸入一個任意整數(shù)m,按序插入到正確位置,輸出插入m后的數(shù)列。Input多組測試數(shù)據(jù),每組輸入一個整數(shù)mOutput輸出插入m后的數(shù)列Sample Input35-590Sample Output0 10 20 30 35 40 50 60 70 80-5 0 10 20 30 40 50 60 70 800 10 20 30 40 50 60 70 80 90#include int main() int n,m,i,l,j,k; int a20,b20; while(scanf(%d,&m)!=EOF) for(i=0;i9;i+) ai=10*i; for(i=0;i10;i+) if(mi;j-) aj=aj-1; ai=m; elsea9=m; for(i=0;i10;i+) if(i!=9) printf(%d ,ai); elseprintf(%dn,ai); 3539: N個數(shù)從小到大排序Time Limit: 1 SecMemory Limit: 64 MBSubmit: 5854Solved: 2635Description輸入一個正整數(shù)N和N個整數(shù),將它們按從小到大的順序進(jìn)行排序后輸出。 Input多組測試數(shù)據(jù),每組輸入一個正整數(shù)N(1N100)和N個整數(shù),用空格分隔。 Output將這N個數(shù)按從小到大的順序重新輸出 Sample Input10 -4 5 12 88 23 -9 2 0 8 105 12 3 4 9 -2Sample Output-9 -4 0 2 5 8 10 12 23 88-2 3 4 9 12#include int main() int i,j,t,n; int a101,b101; while(scanf(%d,&n)!=EOF) for(i=1;i=n;i+) scanf(%d,&ai); for(i=1;i=n;i+) for(j=i;jaj) t=ai; ai=aj; aj=t; elsecontinue; for(i=1;i=n;i+) if(i!=n) printf(%d ,ai); elseprintf(%dn,ai); 3537: 最大數(shù)與數(shù)列最后一個數(shù)交換Time Limit: 1 SecMemory Limit: 64 MBSubmit: 4345Solved: 1875Description輸入一個正整數(shù)n( 1 n 100),再輸入n個整數(shù),將最后一個數(shù)與數(shù)列最大數(shù)交換位置(若最大數(shù)在數(shù)列最后,就不用交換),輸出交換后的n個數(shù)。Input多組測試數(shù)據(jù),每組先輸入一個正整數(shù)n,再輸入n個整數(shù)Output輸出交換后的數(shù)列(即最大數(shù)在數(shù)列最后位置)Sample Input5 3 5 2 8 19 88 33 55 99 44 66 77 22 11Sample Output3 5 2 1 888 33 55 11 44 66 77 22 99#include int main() int i,j,max,n; int a100; while(scanf(%d,&n)!=EOF) for(i=0;in;i+) scanf(%d,&ai); max=a0; j=0; for(i=1;imax) max=ai; j=i; aj=an-1; an-1=max; for(i=0;in-1;i+) printf(%d ,ai); printf(%dn,an-1); return 0; 3886: 零起點(diǎn)學(xué)算法85數(shù)組中插入一個數(shù)Time Limit: 1 SecMemory Limit: 64 MBSubmit: 3497Solved: 1250Description給定有序數(shù)組(從小到大),再給你一個數(shù),要求插入該數(shù)到數(shù)組中并保持順序Input多組測試,每組第一行輸入一個整數(shù)n,然后是n個有序的整數(shù)第二行輸入1個整數(shù)m和1個整數(shù)KOutput將整數(shù)m插入到原數(shù)組中保持順序是升序,然后輸出2行第一行是插入以后的數(shù)組第二行是插入以后的數(shù)組中下標(biāo)值是K的數(shù) n m k不超過20Sample Input3 1 2 53 1Sample Output1 2 3 52#include int main() int n,m,i,l,j,k; int a21,b21; while(scanf(%d,&n)!=EOF) for(i=0;in;i+) scanf(%d,&ai); scanf(%d%d,&m,&k); for(i=0;in;i+) if(mi;j-) aj=aj-1; ai=m; elseai=m; for(i=0;i=n;i+) if(i!=n) printf(%d ,ai); elseprintf(%dn,ai); printf(%dn,ak); 3885: 零起點(diǎn)學(xué)算法84數(shù)組中刪數(shù)IITime Limit: 1 SecMemory Limit: 64 MBSubmit: 4532Solved: 1678Description在給定的數(shù)組中刪除數(shù)Input多組測試,每組第一行輸入1個整數(shù)n(n20),然后是n個整數(shù) 第二行輸入1個整數(shù)m Output刪除在第一行的n個整數(shù)中的數(shù)字m(多個的話都要刪除),然后按照順序輸出剩下的數(shù), Sample Input5 1 2 3 4 33 Sample Output1 2 4#include int main() int n,m,i,l,j,k; int a21,b21; while(scanf(%d,&n)!=EOF) for(i=0;in;i+) scanf(%d,&ai); scanf(%d,&m); for(i=0;in;i+) if(m=ai) if(i!=n-1) continue; elseprintf(n); else if(i!=n-1) printf(%d ,ai); elseprintf(%dn,ai); Problem A: 零起點(diǎn)學(xué)算法83數(shù)組中刪數(shù)Time Limit: 1 SecMemory Limit: 64 MBSubmit: 7443Solved: 2254Description在給定的數(shù)組中刪除一個數(shù) Input多組測試,每組第一行輸入1個整數(shù)n(n20),然后是n個整數(shù) 第二行輸入1個整數(shù)m Output刪除在第一行的n個整數(shù)中第一次出現(xiàn)數(shù)字m并刪除,然后按照順序輸出剩下的數(shù), Sample Input4 1 2 3 43Sample Output1 2 4HINTm有可能在原數(shù)組中找不到,找不到則輸出原數(shù)組#include int main() int n,a20,i,m; while(scanf(%d,&n)!=EOF) for(i=0;in;i+) scanf(%d,&ai); scanf(%d,&m); for(i=0;in;i+) if(ai=m) int j; for(j=i;jn-1;j+) aj=aj+1; break; int t=n-1; if(i!=n)t-; for(i=0;it;i+) printf(%d ,ai); printf(%dn,ai); return 0; Problem A: 零起點(diǎn)學(xué)算法82數(shù)組中查找數(shù)Time Limit: 1 SecMemory Limit: 64 MBSubmit: 7125Solved: 3536Description在給定的數(shù)組中查找一個數(shù)Input多組測試,每組第一行輸入1個整數(shù)n(n20),然后是n個整數(shù)第二行輸入1個整數(shù)mOutput查找在第一行的n個整數(shù)中第一次出現(xiàn)數(shù)字m的下標(biāo)位置并輸出,如果沒有找到則輸出NoSample Input3 4 5 654 2 2 2 22Sample Output10#include int main() int n,a20; int i,j,m; while (scanf(%d, &n) != EOF) for(i=0; in; i+) scanf(%d,&ai); scanf(%d,&m); for(j=0; jn; j+) if(aj=m) printf(%dn,j); break; if(j

注意事項(xiàng)

本文(算法標(biāo)準(zhǔn)答案.docx)為本站會員(good****022)主動上傳,裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng)(點(diǎn)擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因?yàn)榫W(wǎng)速或其他原因下載失敗請重新下載,重復(fù)下載不扣分。




關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!