C語(yǔ)言編程題20210205210607_第1頁(yè)
C語(yǔ)言編程題20210205210607_第2頁(yè)
C語(yǔ)言編程題20210205210607_第3頁(yè)
C語(yǔ)言編程題20210205210607_第4頁(yè)
C語(yǔ)言編程題20210205210607_第5頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余3頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、1.短信計(jì)費(fèi)用手機(jī)發(fā)短信,一般一條短信資費(fèi)為0.1元,但限定每條短信的內(nèi)容在70個(gè)字以內(nèi)(包括70個(gè)字)。如果你所發(fā)送的一條短信超過(guò)了70個(gè)字,則大多數(shù)手機(jī)會(huì)按照每70個(gè)字一條短 信的限制把它分割成多條短信發(fā)送。 假設(shè)已經(jīng)知道你當(dāng)月所發(fā)送的每條短信的字?jǐn)?shù), 試統(tǒng)計(jì) 一下你當(dāng)月短信的總資費(fèi)。#include #include #include #include #include #include #include #define ll long long#define inf 2147483647 using namespace std; int n;int main()cin n;double

2、 ans = 0;for(int i = 1; i x;ans = ans + (x - 1) / 70 + 1) * 0.1; printf(%.1lfn, ans);return 0;2.集體照醫(yī)學(xué)部口腔3班n位同學(xué)約定拍集體照,n大于1且不超過(guò)100。攝影師要求同學(xué)按照身高 站成兩排, 保證第二排的人身高都要大于等于第一排的人, 且第二排的人數(shù)和第一排的人數(shù) 相等或者比第一排多一個(gè)人。輸入n位同學(xué)的身高,請(qǐng)問(wèn)第二排中身高最矮的人的身高是多少?#include #include #include #include #include #include #include #define ll

3、long long #define inf 2147483647 using namespacestd; int n;int a105; int main()while(scanf(%d, &n)if(n = 0)return 0; for(int i = 1; i ai;sort(a + 1, a + n+ 1);cout an / 2 + 1 endl;return 0;3.1020跳格問(wèn)題 有一種游戲,在紙上畫有很多小方格,第一個(gè)方格為起點(diǎn)(S),最后一個(gè)方格為終點(diǎn)。有一 個(gè)棋子,初始位置在起點(diǎn)上,棋子每次可移動(dòng)一次,棋子在起點(diǎn)時(shí),可向前移動(dòng)一個(gè)格子到 第二個(gè)方格內(nèi);棋子在其他方

4、格內(nèi)時(shí),可根據(jù)方格內(nèi)的數(shù)字Ni進(jìn)行移動(dòng)。如果Ni大于零, 就向前移動(dòng)Ni個(gè)格子;如果Ni小于零,就向后移動(dòng)-Ni個(gè)格子;如果Ni等于零,則此次 原地不動(dòng)一次, 在下一步移動(dòng)時(shí)可向前移動(dòng)一步到下一個(gè)格子。顯然, 如果僅按此方案,會(huì) 出現(xiàn)棋子永遠(yuǎn)移動(dòng)不到終點(diǎn)的情形。 為防止這種情況發(fā)生, 我們規(guī)定, 當(dāng)棋子再次來(lái)到它曾 經(jīng)到過(guò)的方格時(shí), 它需要原地不動(dòng)一次, 在下一步移動(dòng)時(shí)可向前移動(dòng)一步到下一個(gè)格子。 按 此方案,棋子總能夠走到終點(diǎn)(F)。如果給定一個(gè)方格圖,試求棋子要走多少步才能從起點(diǎn) 走到終點(diǎn)。( 注:當(dāng)然還可能會(huì)出現(xiàn)向前移動(dòng)Ni個(gè)格子就跑過(guò)終點(diǎn)了, 則把棋子放到終點(diǎn)上。如果Ni太小,使得棋子

5、向后移動(dòng)跑過(guò)了起點(diǎn),則把棋子放到起點(diǎn)上。 )(如圖所示,其中S代表起點(diǎn),F(xiàn)代表終點(diǎn))(只有離開后再次來(lái)到一個(gè)方格時(shí),才算來(lái)到它曾經(jīng)到過(guò)的方格, 包括起點(diǎn)S)#include #include #include #include #include #include #include #define ll long long #define inf 2147483647 using namespace std; int n,ans;int a105; bool vis105; void dfs(int x)if(x n + 2)x = n + 2; if(visx) if(ax)ans += 2;

6、 else ans += 1; dfs(x + 1);elsevisx = 1; if(x = n + 2)return; ans+;dfs(x + ax);int main()scanf(%d, &n);a1 = 1;for(int i = 2; i ai;dfs(1);cout ans endl; return 0;4.配對(duì)堿基鏈脫氧核糖核酸(DNA由兩條互補(bǔ)的堿基鏈以雙螺旋的方式結(jié)合而成。而構(gòu)成DNA的堿基共有4種,分別為腺瞟呤(A)、鳥嘌呤(G、胸腺嘧啶(T和胞嘧啶(C)。我們知道,在兩 條互補(bǔ)堿基鏈的對(duì)應(yīng)位置上, 腺瞟呤總是和胸腺嘧啶配對(duì), 鳥嘌呤總是和胞嘧啶配對(duì)。 你的 任

7、務(wù)就是根據(jù)一條單鏈上的堿基序列,給出對(duì)應(yīng)的互補(bǔ)鏈上的堿基序列。#include #include #include #include #include #include #include #define ll long long#define inf 2147483647 using namespace std;int n;string x;int main()scanf(%d, &n);for(int i = 1; i = n; i+) x;for(int j = 0; j x.length(); j+) if(xj = T) xj = A;else if(xj = A)xj = T

8、;else if(xj = C) xj = G;elsexj = C;cout x endl; return 0;5.打魚還是曬網(wǎng) 中國(guó)有句俗語(yǔ)叫“三天打魚兩天曬網(wǎng)” 。某人從1990年1月1日起開始“三天打魚兩 天曬網(wǎng)”,問(wèn)這個(gè)人在以后的某一天中是“打魚”還是“曬網(wǎng)” 注意要區(qū)分閏年和不是閏年的兩種情況#include #include #include #include #include #include #include #define ll long long#define inf 2147483647 using namespace std;int y, m, d;int mm12

9、= 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31; int tot;int main()cin y m d;for(int i = 1990; i y; i+)if(i % 4 = 0 & i % 100 != 0) | i % 400 = 0) tot += 366;else tot += 365;for(int i = 1; i m; i+)if(y % 4 = 0 & y % 100 != 0) | y % 400 = 0) & i = 2) tot += 29;elsetot += mmi - 1;tot += (

10、d - 1);if(tot % 5 = 2) puts(fishing);else puts(sleeping);return 0;6.優(yōu)先隊(duì)列 給定一個(gè)初始數(shù)字集合,對(duì)其做如下兩種操作:1.添加一個(gè)新的數(shù)字2.將集合中當(dāng)前最小的數(shù)字取出 (輸出并刪除) ,如果最小的數(shù)字有多個(gè), 只取出其中一個(gè)。#include #include #include #include #include #include #include #include #define ll long long#define inf 2147483647 using namespace std;int n, m;struct

11、dataint a200005;int cnt;bool empty() return cnt = 0;void push(int x) a+cnt = x; int p = cnt; while(p 1 & ap ap / 2) swap(ap, ap / 2);p = p / 2;int top() return a1;void down(int x)int t = x cnt)return;if(t + 1 = cnt & at + 1 at) t+;if(at n;for(int i = 1; i x; q.push(x);cin m;char opt15;for(in

12、t i = 1; i = m; i+)scanf(%s, opt);if(opt0 = E) if(q.empty() puts(NULL);elsecout q.top() endl; q.pop(); else x; q.push(x); return 0;7.護(hù)林員蓋房子 在一片保護(hù)林中,護(hù)林員想要蓋一座房子來(lái)居住,但他不能砍伐任何樹木。 現(xiàn)在請(qǐng)你幫他計(jì)算:保護(hù)林中所能用來(lái)蓋房子的矩形空地的最大面積。#include #include #include #include #include #include #include #include #define ll long long #d

13、efine inf 2147483647using namespace std; int n, m;int ans;int v2525;bool check(int a, int b, int c, int d)for(int i = a; i = c; i+)for(int j = b; j n m;for(int i = 1; i = n; i+)for(int j = 1; j vij;for(int i = 1; i = n; i+)for(int j = 1; j = m; j+)for(int k = i; k = n; k+)for(int l = j; l = m; l+) i

14、f(check(i, j, k, l) ans = max(ans, (k - i + 1) * (l -j + 1); cout ans endl;return 0;8.汽車限行 為了緩解交通壓力、減少空氣污染,B市市政府決定在工作日(周一至周五)對(duì)機(jī)動(dòng)車進(jìn)行 限行,每輛機(jī)動(dòng)車每周將有一個(gè)工作日不能出行,但周末不限行。假設(shè)該政策從2000年1月1日起開始執(zhí)行。限行安排為: 尾號(hào)為 尾號(hào)為 尾號(hào)為 尾號(hào)為 尾號(hào)為 已知2000年1月1日為周六,現(xiàn)在給出一些日期和車牌號(hào),求問(wèn) 該 機(jī)動(dòng) 車 在該 天 是否限行。#include #include #include #include #includ

15、e #include #include #define ll long long#define inf 2147483647 using namespace std;int T;int y, m, d;int mm12 = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31; int main()1和6:周一限行2和7:周二限行3和8:周三限行4和9:周四限行5、0和字母:周五限行cin T;while(T-)char ch;cin y ch m ch d;string s;cin s;int day, tot = 0;if(s5 9 | s5 0)d

16、ay = 5; else day = (s5 - 0) % 5; if(day = 0)day = 5;for(int i = 2000; i y; i+)if(i % 4 = 0 & i % 100 != 0) | i % 400 = 0) tot += 366;else tot += 365;for(int i = 1; i m; i+)if(y % 4 = 0 & y % 100 != 0) | y % 400 = 0) & i = 2) tot += 29;elsetot += mmi - 1;tot += (d - 1);if(tot + 6 - 1) % 7

17、 + 1 = day) puts(yes);else puts(no);return 0;9.人工智能 人工智能一直是計(jì)算機(jī)學(xué)所追求的一個(gè)很高的境界, 力力求達(dá)到這個(gè)境界。 這道題也跟“人工智能”有關(guān)。 學(xué)過(guò)初中物理的同學(xué)都應(yīng)該知道物理學(xué)中的這個(gè)公式 如果給定其中的任意兩個(gè)值,第三個(gè)值都是很容易求的,#include #include #include #include #include #include #include #include #define ll long long #define inf 2147483647 using namespace std; int T;string s;map mp;double get(int x)double v = 0, t = 1;for(int i = x; i = 0 & si T;char ch;ch = getchar();for(int t =

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論