安徽科技学院 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"<

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
#include
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
#include
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<
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
#include
#include
#include
#include
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
#include
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
#include
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
#include
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
#include
#include
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<= 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;
}

最后排名:

安徽科技学院 2014-2015-2学期计算机14级12班《C语言程序设计II》期末考试_第1张图片

安徽科技学院 2014-2015-2学期计算机14级12班《C语言程序设计II》期末考试_第2张图片


安徽科技学院 2014-2015-2学期计算机14级12班《C语言程序设计II》期末考试_第3张图片

安徽科技学院 2014-2015-2学期计算机14级12班《C语言程序设计II》期末考试_第4张图片
最后成绩也可看到,基本都是5道、4道题,最少2题,都及格了,这和我们去年的期末考试难度降得不要太多,大家开开心心结束了为期两学期的c语言学习,编程也算入门了,后面的路还有很长,望大家不忘努力,努力什么时候都不晚,珍惜时间,大学四年很快,很快。



你可能感兴趣的:(akoj,汇总,安科OJ题解,期末考试,C语言,oj)