




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、第一題(60分):按要求分解字符串,輸入兩個數(shù)M , N ; M代表輸入的M串字符串,N代表輸出的每串字符串的位數(shù),不夠補0。例如:輸入2,8,a I »abc“ 123456789 ” 則輸出為 “ abc00000 ” , “ 12345678“ , ”90000000 ”cpp view plaincopy1.轉載請標明出處,原文地址:htt P: /2.#include<iostream>3.#include<cstdio>4.using names pace std;5.6.void solve( char *str,int n , int7.8.i
2、nt i , j , k , quotient , remainder;9.quotient = len / n;10.remainder = len - n * quotient;11.12.for (i = 0 ; i < len ; i += n)13.14.if (len - i < n)15.16.k = n - len + i;17.for (j =i ; j < len ; +j)18.p rintf("%c" , strj)19.for (j =0 ; j < k ; +j)20.pu tchar('0');21.22
3、.else23.24.for (j = i;j < i + n ; +j)25.p rintf("%c" , strj);26.27.pu tchar('');28.29.printf("n");30.31.32.int main( void )J33.len)/原字符串被分解的個數(shù)/剩余的字符串的個數(shù)34.int i,m , n , len;35.charstr1000;36.37.while(scanf( "%d %d" , &m38.39.for (i = 0 ; i < m ; +i)40.
4、41.scanf("%s" , str);42.len=strlen(str);43.solve(str , n , len);44.45.46.return 0;47.,&n) != EOF)第一題:拼音轉數(shù)字輸入是一個只包含拼音的字符串,請輸出對應的數(shù)字序列。轉換關系如下:描述:拼音yi ersan si wu liu qi ba jiu阿拉伯數(shù)字456789cpp view plaincopy輸入字符只包含小寫字母,所有字符都可以正好匹配運行時間限制:無限制內(nèi)存限制:無限制輸入:一行字符串,長度小于1000輸出:一行字符(數(shù)字)串樣例輸入:yiersa nsi
5、樣例輸出:12341.轉載請標明出處,原文地址:htt P: /2.#include<iostream>3.#include<cstdio>4.using names pace std;5.6.voidsolve( char *str ,intlen)7.8.inti;9.10.for(i = 0 ; i < len ;)11.12.switch (stri)13.14.case 'y':15.p utchar('1');16.i += 2;17.break ;18.case 'e19.p utchar('2'
6、;);20.i += 2;21.break ;22.case 's'23.if (stri +1='a')24.25.pu tchar('3');26.i += 3;27.28.else29.30.pu tchar('4');31.i += 2;32.33.break ;34.case 'w'35.p utchar('5');36.i += 2;37.break ;38.case 'l'39.p utchar('6');40.i += 3;41.break ;42.c
7、ase 'q':43.p utchar('7');44.i += 2;45.break46.case 'b':47.p utchar(48.i += 2;49.break50.case j'51.p utchar(52.i += 3;53.break54.55.56.printf("n");57. 58.59. intmain( void )60. 61.int len;62.char str1OOO;63.64.while (scanf('65.66.len = strlen(str);67.solve(st
8、r , len);68. 69.return 0;70. "%s" , str) != EOF)8 );'9');第二題:去除重復字符并排序運行時間限制:無限制內(nèi)容限制:無限制輸入:字符串輸出:去除重復字符并排序的字符串樣例輸入:aabcdefff樣例輸出:abcdef1.轉載請標明出處,原文地址:htt P: /2.#includeviostream>3.#includevcstdio>4.#includevmemory>5.using names pace std;6.7.voidsolve( char *str ,intlen)8.9
9、.int i , hash256;10.memset(hash , 0 ,sizeof(hash);11.12.for (i = 0 ; i v len ; +i)13.14.if (0 = hashstri)15.hashstri = 1;16.17.for (i = 0 ; i v 256 ; +i)18.19.if (0 != hashi)20.p utchar(i);21.22.printf("n");23.24.25.intmain( void )26.27.int len;28.char str1000;29.30.while (scanf( "%s&
10、quot; , str) != EOF)31.32.len = strlen(str);33.solve(str , len);34.35.return 0;J36.第三題:等式變換輸入一個正整數(shù)X,在下面的等式左邊的數(shù)字之間添加 +號或者-號,使得等式成立。比如: 12-34+5-67+89 = 5 1+23+4-5+6-7-8-9 = 5 請編寫程序,統(tǒng)計滿足輸入整數(shù)的所有整數(shù)個數(shù)。18.22.輸入:正整數(shù),等式右邊的數(shù)字輸出:使該等式成立的個數(shù)樣例輸入:樣例輸出:21cpp view plaincopy1.轉載請標明出處,原文地址:htt P: /2.#include<iostre
11、am>3.#include<cstdio>4.using names pace std;5.6.7.int op s21;const char sym3 = '+'8.int result , num;9.10.void dfs( int layer, int currentResult,int last Op, int lastSum)12.11.13.lastSum *= (layer > 9) ? 100 : 10;lastSum += layer;14.if (layer = 9)15.16.17.currentResult += (last O
12、p) ? (-1 * lastSum) : lastSum;if (currentResult = result)19.+num;20.printf("1");21.for(int i = 2 ; i <= 9 ; +i)23.if (symopsi-1 !=24.p rintf("%c " , symopsi-1);25.p rintf("%d", i);26.27.printf("=%dn", result);28.29.return30.31.32.op slayer = 2;dfs(layer + 1 , currentResult , last Op , lastSum);/Continue33.currentResult += (lastO p)? (-1 * lastSum) : lastSum;34.op slayer = 0;35.dfs(layer + 1 , currentResult , 0,0);/P lus36.op slayer = 1;37.dfs(layer
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030年中國電子地圖數(shù)字地圖產(chǎn)業(yè)發(fā)展趨勢規(guī)劃分析報告
- 2025-2030年中國煤焦油行業(yè)運行態(tài)勢及投資戰(zhàn)略研究報告
- 2025-2030年中國泡沫塑料市場運行態(tài)勢及投資戰(zhàn)略研究報告
- 2025-2030年中國杜松子酒產(chǎn)業(yè)運行狀況與投資戰(zhàn)略研究報告
- 2025-2030年中國服裝零售市場發(fā)展趨勢與投資戰(zhàn)略研究報告
- 2025-2030年中國智能型沖擊記錄儀行業(yè)市場現(xiàn)狀分析規(guī)劃研究報告
- 2025-2030年中國教學專用儀器行業(yè)競爭格局及前景趨勢分析報告
- 2025-2030年中國懷山藥行業(yè)發(fā)展趨勢規(guī)劃研究報告
- 2025-2030年中國當歸市場運行態(tài)勢及投資戰(zhàn)略研究報告
- 2025-2030年中國姜黃油行業(yè)市場競爭狀況及發(fā)展趨勢分析報告
- 生而為贏自燃成陽-開學第一課發(fā)言稿
- 2024年設備監(jiān)理師考試題庫及答案參考
- 公司外派學習合同范例
- 2025年中國國投高新產(chǎn)業(yè)投資集團招聘筆試參考題庫含答案解析
- 安徽省合肥市包河區(qū) 2024-2025學年九年級上學期期末道德與法治試卷(含答案)
- 廣州電視塔鋼結構施工方案
- 2024年湖南鐵路科技職業(yè)技術學院高職單招數(shù)學歷年參考題庫含答案解析
- 年產(chǎn)10噸功能益生菌凍干粉的工廠設計改
- 核物理實驗方法全冊配套最完整精品課件
- 理論力學課件00796
- 學習疊層母排必須知道的電力知識
評論
0/150
提交評論