安徽科技學院 2014-2015-2學期計算機14級12班《C語言程序設計II》期末考試

Contest - 2014-2015-2學期計算機14級12班《C語言程序設計II》期末考試

Start time:  2015-07-03 19:05:00.0  End time:  2015-07-03 21:35:00.0
Current System Time:  2015-07-06 01:12:32.52  Contest Status:   Ended

考試時間爲7:00-10:00,請攜帶身份學生證參加考試。考試可以攜帶任何紙質資料(圖書,草稿紙,代碼清單,上課筆記等),但是禁止攜帶任何電子材料(包括手機,計算器,筆記本電腦等);考試過程中務必獨立答題,發現任何作弊或者違紀行爲本課成績一律以0分記,並保留進一步處理的權利!
Problem Id Title
1321 Problem A 10000小時定律
1319 Problem B 四方定理
1312 Problem C A difficult problem
1313 Problem D DNF又爆滿啦
1314 Problem E 奇幻數字
1315 Problem F 差值最大
1316 Problem G 字符串替換
1107 Problem H 閏年

[Standings]  [Status]  [Statistics]


本文由csdn-jtahstu原創,轉載請註明出處,歡迎志同道合的朋友一起交流學習。本人QQ:1373758426和csdn博客地址,鏈接:http://blog.csdn.net/jtahstu  
此次一年級題目由本人出題,由於考慮到這是他們最後一次期末考試和出題要求要簡單有趣,所以題目不是太難,畢竟還是要讓大家順利通過,取個好成績,培養興趣。因爲絕大部分同學在這次考試之後就不會再在OJ上刷題了,以後大家幾乎也不會再想去刷題了,現在顧及到考試所以爲了取得好成績,以後沒有壓力之後,再這樣努力的也不會再剩下多少了。
說了這麼多,此次考試,作爲大家的最後一次“OJ刷題”和檢測C語言編程的能力,儘量讓題目簡單有趣,控制最低分和最高分,讓基礎不好的同學增強信心,讓基礎好的同學不過度的驕傲自滿,體會數據結構的重要性和算法的巧妙。最後祝願同學們取得一個好成績,哈,實際老趙給分也是相當高的了。
由於題目是亂序加進去的,所以下面寫博客的時候,不按上面的題目順序來,按難以程度排列,ok,let's go .
1107、

閏年

Time Limit:1000MS  Memory Limit:65536K
Total Submit:577 Accepted:382

Description

輸入年份判斷是否是閏年,如果是則輸出“yes"否則輸出"no" 
閏年規則爲:四年一閏,百年不閏,四百年再閏;如2012爲閏年,但1900年不是閏年,2000年是閏年喲。

Input

輸入年份判斷是否是閏年,

Output

如果是則輸出“yes"否則輸出"no" 

Sample Input

1900

Sample Output

no

Source

lrj程序入門

[Submit]   [Go Back]   [Status]   [Discuss]

表示這道題不是我出的,是最後爲了讓所有人最少AC一題的目標,從OJ上直接拿來的,簡單,代碼也少。

#include "iostream"//n久以前寫的,姑且一看
using namespace std;
int main()
{
	int year;
	cin>>year;
	if((year%4==0&&year%100!=0)||year%400==0)
		cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

1312、

A difficult problem

Time Limit:1000MS  Memory Limit:65536K
Total Submit:25 Accepted:11

Description

Today, I want to take a few minutes to speak with you-directly and clearly-about Ebola: what we're doing about it, and what you need to know. Because meeting a public health challenge like this isn't just a job for government. All of us-citizens, leaders, the media-have a responsibility and a role to play. This is a serious disease, but we can't give in to hysteria or fear-because that only makes it harder to get people the accurate information they need. We have to be guided by the science. We have to remember the basic facts. 
First, what we're seeing now is not an "outbreak" or an "epidemic" of Ebola in America. We're a nation of more than 300 million people. To date, we've seen three cases of Ebola diagnosed here-the man who contracted the disease in Liberia, came here and sadly died; the two courageous nurses who were infected while they were treating him. Our thoughts and our prayers are with them, and we're doing everything we can to give them the best care possible. 
Now, even one infection is too many. At the same time, we have to keep this in perspective. As our public health experts point out, every year thousands of Americans die from the flu. 
Second, Ebola is actually a difficult disease to catch. It's not transmitted through the air like the flu. You cannot get it from just riding on a plane or a bus. The only way that a person can contract the disease is by coming into direct contact with the bodily fluids of somebody who is already showing symptoms. I've met and hugged some of the doctors and nurses who've treated Ebola patients. I've met with an Ebola patient who recovered, right in the Oval Office. 
And I'm fine. 
Third, we know how to fight this disease. We know the protocols. And we know that when they're followed, they work. So far, five Americans who got infected with Ebola in West Africa have been brought back to the United States-and all five have been treated safely, without infecting healthcare workers. 
And this week, at my direction, we're stepping up our efforts. Additional CDC personnel are on the scene in Dallas and Cleveland. We're working quickly to track and monitor anyone who may have been in close contact with someone showing symptoms. We're sharing lessons learned so other hospitals don't repeat the mistakes that happened in Dallas. The CDC's new Ebola rapid response teams will deploy quickly to help hospitals implement the right protocols. New screening measures are now in place at airports that receive nearly all passengers arriving from Liberia, Guinea and Sierra Leone. And we'll continue to constantly review our measures, and update them as needed, to make sure we're doing everything we can to keep Americans safe. 
Finally, we can't just cut ourselves off from West Africa, where this disease is raging. Our medical experts tell us that the best way to stop this disease is to stop it at its source-before it spreads even wider and becomes even more difficult to contain. Trying to seal off an entire region of the world-if that were even possible-could actually make the situation worse. It would make it harder to move health workers and supplies back and forth. Experience shows that it could also cause people in the affected region to change their travel, to evade screening, and make the disease even harder to track. 
So the United States will continue to help lead the global response in West Africa. Because if we want to protect Americans from Ebola here at home, we have to end it over there. And as our civilian and military personnel serve in the region, their safety and health will remain a top priority. 
As I've said before, fighting this disease will take time. Before this is over, we may see more isolated cases here in America. But we know how to wage this fight. And if we take the steps that are necessary, if we're guided by the science-the facts, not fear-then I am absolutely confident that we can prevent a serious outbreak here in the United States, and we can continue to lead the world in this urgent effort. 

So here's the problem that when I give you two numbers you should give me the (opposite of the first number) plus one.

Input

You will be given two numbers in the input 
(where the num is belong to the integer) 
Multiple sets of test data, end with EOF

Output

please read the problem .

Sample Input

12 34567891011
-999 753951

Sample Output

-11
1000

Hint

這是一道難題。。。。。。。。目測亞洲區域賽難度。。。。。。 
opposite 取相反數的意思

Source

[Submit]   [Go Back]   [Status]   [Discuss]

這題我都不想再講了,同學們看到英文題就感覺很難,外表不代表內在哎,最後在hint裏都加上了oppsite的意思了,都沒人寫,表示我非常傷心,唉,,,題意很簡單第一個數取反然後加一,注意使用long long

/**
 * Project Name: C++
 * File Name: A_difficult_problem.cpp
 * Created on: 2015年6月23日 下午2:57:16
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */
#include<iostream>
#include<cstdlib>
using namespace std;
int main() {
	//freopen("A.in", "r", stdin);
	//freopen("A.out", "w", stdout);
	long long a, b;
	while (cin >> a >> b) {
		cout << -a + 1 << endl;
	}
	return 0;
}
1313、

DNF又爆滿啦

Time Limit:1000MS  Memory Limit:65536K
Total Submit:113 Accepted:78

Description

《地下城與勇士》是一款韓國網絡遊戲公司NEOPLE開發的免費角色扮演2D遊戲,由三星電子發行,並於2005年8月在韓國正式發佈。中國則由騰訊遊戲代理髮行於2008年6月。 
該遊戲是一款2D卷軸式橫版格鬥過關網絡遊戲,大量繼承了衆多家用機、街機2D格鬥遊戲的特色。以任務引導角色成長爲中心,結合副本、PVP、PVE爲輔,與其他網絡遊戲同樣具有裝備與等級的改變,並擁有共上千種裝備道具。每個人物有11個道具裝備位置,在遊戲中可以允許最多4個玩家進行組隊挑戰關卡,同樣也可以進行4對4的PK。 
這一天jtahstu閒來無事又想上游戲刷幾個圖了,但是在登上游戲選擇頻道的時候,他看到有的頻道爆滿,有的頻道擁擠,有的順暢。好奇的他便產生了一個疑問,如果,每一個上游戲的人都很自覺,按頻道依次選擇,爆滿則選擇下一個,直至有一個頻道可以進去爲止,不會出現有玩家一個頻道也進不去的情況。 
我們知道安徽一區有67個頻道,假設一個頻道最大能容納1000人同時在線,這時會顯示爆滿,500-999人同時在線時頻道顯示擁擠,0-499人同時在線時顯示順暢。

Input

多組測試數據 
輸入目前安徽一區的同時在線人數n,n符合題意。 
數據以EOF結束

Output

每個輸出一行,依次輸出爆滿的頻道個數,擁擠的頻道個數和順暢的頻道個數

Sample Input

12345
20000
66666

Sample Output

12 0 55
20 0 47
66 1 0

Source

[Submit]   [Go Back]   [Status]   [Discuss]

哈,說道這題,當時我地下城在掛機就胡亂想到的,簡單的一塌糊塗

/**
 * Project Name: C++
 * File Name: DNF.cpp
 * Created on: 2015年6月23日 下午11:58:40
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */
#include<iostream>
#include<cstdlib>
using namespace std;
int main() {
  //  freopen("A.in", "r", stdin);
	//freopen("A.out", "w", stdout);
    int n;
    while(cin>>n) {
        int bao=0,yong=0,shun=0;
        bao=n/1000;
        if(n%1000>=500)
            yong++;
        shun=67-bao-yong;
        cout<<bao<<" "<<yong<<" "<<shun<<endl;
    }
    return 0;
}
1314、

奇幻數字

Time Limit:1000MS  Memory Limit:65536K
Total Submit:96 Accepted:67

Description

給定兩個整數m,n,統計1-n的整數中有多少個奇幻數字,只要滿足以下兩個條件的任意一個,我們就稱其爲奇幻數字. 
1、是m的倍數 
2、數字中包含m

Input

第一個數是T,表示測試數據的組數。 後面有T行,包括兩個整數m和n,m∈[1,9]且m∈Z n∈[1,1000000]

Output

輸出奇幻數字的個數。

Sample Input

2
3 20
2 100

Sample Output

7
55

Source

[Submit]   [Go Back]   [Status]   [Discuss]

數字的模和除運算,沒什麼難度,可能不少人對分離一個數的各個位有疑惑,監考的時候發現好多人竟然就是寫七個式子求然後比較,我只想說,我不想難爲你,這要是很大的範圍那怎麼行呢,還是用循環吧。

/**
 * Project Name: C++
 * File Name: 奇幻數字.cpp
 * Created on: 2015年6月23日 下午3:32:48
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
bool test1(int i, int m) {
    if (i % m == 0)
        return true;
    return false;
}
bool test2(int i, int m) {
    int i1 = i;
    while (i1) {
        if (i1 % 10 == m)
            return true;
        i1 /= 10;
    }
    return false;
}
int main() {
    //freopen("A.in", "r", stdin);
    //freopen("A.out", "w", stdout);
    int t, m, n;
    cin >> t;
    while (t--) {
        int count = 0;
        cin >> m >> n;
        for (int i = 1; i <= n; i++)
            if (test1(i, m) || test2(i, m))
                count++;
        cout << count << endl;
    }
    return 0;
}

1315、

差值最大

Time Limit:1000MS  Memory Limit:65536K
Total Submit:78 Accepted:42

Description

在給定的一個m*n的矩陣中,計算各列或各行累加和中最大值與最小值的差 
例如,給定一個2*2的矩陣 
1 5 
6 3 
則各列和各行的累加和依次爲7,8,6,9,則所求的差值爲Max-Min=9-6=3。

Input

多組測試數據 
第一行爲m*n(0 < m,n <= 50)的矩陣,矩陣值和累加和都在int範圍內 
程序以0 0輸入結束

Output

輸出最大的差值,每組數據輸出一行

Sample Input

3 3
1 4 7
2 5 8
3 6 9
0 0

Sample Output

18

Source

[Submit]   [Go Back]   [Status]   [Discuss]

二維數組的求和,知道行和列怎麼求和,雖然這題看上去不難,實際上很多算法就是在操縱i,j值,實現一些很巧妙地運算,需要大量訓練,細細體會。

/**
 * Project Name: C++
 * File Name: 差值最大.cpp
 * Created on: 2015年6月23日 下午8:15:39
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */
#include<iostream>
#include<cstdlib>
using namespace std;
int main() {
    //freopen("A.in", "r", stdin);
   // freopen("A.out", "w", stdout);
	int m, n;
	while (cin >> m >> n) {
		if (m == 0 && n == 0)
			break;
		int a[55][55] = { 0 }, max = -1, min = 10000000;
		for (int i = 0; i < m; i++)
			for (int j = 0; j < n; j++)
				cin >> a[i][j];
		for (int i = 0; i < m; i++) { //計算每行累加和的最大最小值
			int sum = 0;
			for (int j = 0; j < n; j++) {
				sum += a[i][j];
			}
			if (sum > max)
				max = sum;
			if (sum < min)
				min = sum;
		}
		for (int j = 0; j < n; j++) { //計算每列累加和的最大最小值
			int summ = 0;
			for (int i = 0; i < m; i++) {
				summ += a[i][j];
			}
			if (summ > max)
				max = summ;
			if (summ < min)
				min = summ;
		}
		cout << max - min << endl;
	}
	return 0;
}
1316、

字符串替換

Time Limit:1000MS  Memory Limit:65536K
Total Submit:124 Accepted:75

Description

編寫一個程序實現將字符串中的所有"you"替換成"we",如果不包含"you",則原樣輸出。

Input

輸入包含多行數據 
每行數據是一個字符串,長度不超過1000 
數據以EOF結束

Output

對於輸入的每一行,輸出替換後的字符串

Sample Input

you are good man
you And Me
You with you

Sample Output

we are good man
we And Me
You with we

Source

[Submit]   [Go Back]   [Status]   [Discuss]

考慮題目難度沒有給一些奇怪的字符,讓很多人給第三個位置隨便符一個值都能過,因爲測試數據就都是字母,不想搞難了,畢竟就是水題。

/**
 * Project Name: C++
 * File Name: 字符串替換.cpp
 * Created on: 2015年6月23日 下午10:41:22
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */
#include<iostream>
#include<string>
using namespace std;
int main() {
    //freopen("A.in", "r", stdin);
   // freopen("A.out", "w", stdout);
    string s;
    while (getline(cin, s)) {
        string s2 = "we";
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == 'y' && s[i + 1] == 'o' && s[i + 2] == 'u') {
                s.replace(i, 3, s2);
            }
        }
        cout << s << endl;
    }
    return 0;
}
1319、

四方定理

Time Limit:1000MS  Memory Limit:65536K
Total Submit:27 Accepted:10

Description

數論中著名的“四方定理”講的是:所有自然數至多隻要用四個數的平方和就可以表示。

Input

輸入包含多行數據 
每行輸入一個n,(1<=n<=10000) 
數據以EOF結束

Output

由於可能會出現多種情況,依次輸出最小的a,b,c,d即可 
即輸出最小的a,然後輸出最小的b,依此類推

Sample Input

110
211
520

Sample Output

0 1 3 10
0 3 9 11
0 0 6 22

Source

[Submit]   [Go Back]   [Status]   [Discuss]

暴力可以過,沒啥難度,但是你要知道break只能提跳一個for循環啊,監考時給不下三個人改了這題代碼,很多人不知道

/**
 * Project Name: C++
 * File Name: 四方定理.cpp
 * Created on: 2015年6月23日 下午11:08:40
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */
#include<iostream>
#include<cstdlib>
using namespace std;
int main() {
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
	int n;
	while (cin >> n) {
		bool flag = true;
		for (int i = 0; i * i <= n; i++) //窮舉
			if (flag) {
				for (int j = 0; j * j <= n; j++)
					if (flag)
						for (int k = 0; k * k <= n; k++)
							if (flag)
								for (int l = 0; l*l <= n; l++)
									if (i * i + j * j + k * k + l * l == n) {
										cout << i << " " << j << " " << k << " "
												<< l << endl;
										flag = false;
									}
			}
	}
	return 0;
}
1321、

10000小時定律

Time Limit:1000MS  Memory Limit:65536K
Total Submit:10 Accepted:2

Description

作家格拉德威爾在《異類》一書中指出: 
“人們眼中的天才之所以卓越非凡,並非天資超人一等,而是付出了持續不斷的努力。1萬小時的錘鍊是任何人從平凡變成超凡的必要條件。” 
他將此稱爲“一萬小時定律”。要成爲某個領域的專家,需要10000小時,按比例計算就是:如果每天工作八個小時,一週工作五天,那麼成爲一個領域的專家至少需要五年。這就是一萬小時定律。 
現在計算機專業的陶陶想成爲Web方向的大牛,那麼按照10000小時定律,她要努力到什麼時候才能成爲大牛呢? 
例如:陶陶現在從2015/6/23日開始努力,每天訓練1小時,(假設一週七天,一年365天她都在努力),總共需要10000/1=10000天(如果非整數天,向上取整),則她需要到2042/12/7這一天才能成爲真正的大牛。簡單點說,今天是2015/6/23,她需要努力1天,則成爲大牛的時間就是2015/6/24。 
提示:由於陶陶生活在二次元,並不用考慮閏年的情況,一年就只有365天。

Input

多組測試數據,輸入以EOF結束 
輸入給定的日期(如2015/6/23)和每天努力的小時數h(0 < h <= 24)

Output

輸出她成爲大牛的日期,輸出格式見示例

Sample Input

2015/6/23 1
2015/9/1 8

Sample Output

2042/11/14
2019/2/2

Hint

其實對於成功者來說,不管練習的過程枯燥與否,有趣與否,他們都必將付出遠遠超出常人的代價。心甘情願花上一萬個小時來打通任督二脈的人,大都不是尋常之輩。

Source

[Submit]   [Go Back]   [Status]   [Discuss]

這題還是我上JAVA課想出來的,加上之前看到的這個勵志小故事,結果就想出來這麼一道題,雖然就有兩個人提交,雖然那寫的也不對,但題目還是出了一點問題,我自己寫的代碼有點問題,導致測試數據不對,實際是有的對,有的又不對,這題廢了我很長時間的,最後考完試把測試數據和標程改過來的,還是挺抱歉的。

/**
 * Project Name: C++
 * File Name: 10000Hours.cpp
 * Created on: 2015年6月23日 上午10:04:18
 * Author: jtahstu
 * QQ: 1373758426 E-mail:[email protected]
 * Copyright (c) 2015, jtahstu , All Rights Reserved.
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int N = 10000;
const int d[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int calc(int month, int day) { //計算這一年還有多少天
	int days = 0;
	for (int i = month + 1; i <= 12; i++)
		days += d[i];
	return days + (d[month] - day + 1);
}
int main() {
   // freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);

	int Satrt_year, Start_month, Start_day, hour;
	while (~scanf("%d/%d/%d %d", &Satrt_year, &Start_month, &Start_day, &hour)) {
		int days;
		int End_year = Satrt_year, End_month = Start_month, End_day;
		if (N % hour)
			days = N / hour + 1;
		else
			days = N / hour;
		while (days >= 365) {
			End_year++;
			days -= 365;
		}
		if (calc(Start_month, Start_day) > days) { //如果就在這一年內
		    //cout<<calc(Start_month, Start_day) <<endl;
		    //cout<<days<<endl;
			if (days >= d[Start_month] - Start_day + 1) { //如果不在起始的月份
				End_day = 0;
				End_month++;
				days =days-( d[Start_month] - Start_day + 1);
				for (int i = Start_month + 1; i <= 12; i++) {
					if (days >= d[i]) {
						End_month++;
						days -= d[i];
					}
				}
                    End_day=days;//臥槽,這裏多次一舉的,媽蛋
//				End_day = Start_day + days; //這裏相加可能會大於這個月的天數
//				if (End_day > d[End_month]) {
//					End_month++;
//					End_day -= d[End_month - 1];
//				}
			} else { //如果恰好在起始的月份
				End_day = Start_day + days;
			}
		} else { //如果到達下一年
			End_month = 1;
			End_day = 0;
			days -= calc(Start_month, Start_day);
			End_year++;
			for (int i = 1; i <= 12; i++) {
				if (days >= d[i]) {
					End_month++;
					days -= d[i];
				}
			}
			End_day += days;
		}
		cout << End_year << "/" << End_month << "/" << End_day << endl;
	}
	return 0;
}

最後排名:







最後成績也可看到,基本都是5道、4道題,最少2題,都及格了,這和我們去年的期末考試難度降得不要太多,大家開開心心結束了爲期兩學期的c語言學習,編程也算入門了,後面的路還有很長,望大家不忘努力,努力什麼時候都不晚,珍惜時間,大學四年很快,很快。



發佈了189 篇原創文章 · 獲贊 30 · 訪問量 160萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章