随笔分类 -  sicily

摘要:DescriptionRewrite Exercise 7.18 using the string class with the following function header:bool isAnagram(const string &s1, const string &s2)Two words are anagrams if they contain the same letters in any order.自己班的作业写到烦了又跑去蹭别人班的题做……因为这是道改编题,不知道原题的要求是什么,纠结了很久=。=这里的anagram的要求应该是两个字符串具有相同的字符,每种 阅读全文
posted @ 2013-03-16 20:46 Joyee 阅读(266) 评论(0) 推荐(0)
摘要:Description通过完成类的定义及其实 现:ClassWithCounter,使用下面提供的主函数,可以得到Sample Output中的输出。鉴于大家还没有学习到static成员变量,在你的代码中可以采用全局变量做对象个数的统计。简单地讲,该全局变量初始为0,在 每个构造函数中自增1。在该类中,有一个成员变量记录着自己是第几个。Output在 默认的构造函数中输出如下内容:ClassWithCounter::ClassWithCounter(): id。(注意冒号与id间有一个空格,输出一行)。在析构函数中输出一下内 容:ClassWithCounter::~ClassWithCoun 阅读全文
posted @ 2013-03-13 17:12 Joyee 阅读(211) 评论(0) 推荐(0)
摘要:Description“ 只要我离开了你的世界,无论你做过什么,我都能忘记你回到从前!”小PY今天很小清新的,大家不要说他腹黑啊。他知道今天大家都学习了析构函数!现在请大 家帮他实现一个类AutoReset,这个类的功能是在一个作用域开始的时候,保存某个变量的值,而当该作用域结束的时候能够实现变量值的Reset。比 如以下这个例子:实现下面这个类:class AutoReset {public: AutoReset(int *scoped_variable, int new_value); ~AutoReset();private: int *scoped_variable_; int ori 阅读全文
posted @ 2013-03-13 17:09 Joyee 阅读(550) 评论(0) 推荐(0)
摘要:DescriptionDesign a class name Time. The class contains:Data field hour, minute, and second that represent a time.A no-arg constructor that creates a Time object for the current time. (The data fields value will represent the current time.)A constructor that constructs a Time object with a specified 阅读全文
posted @ 2013-03-06 01:25 Joyee 阅读(628) 评论(0) 推荐(0)
摘要:7601. calendarDescription小py是一个熊孩子,他 很想知道某一个日期是星期几,于是他找到了你。请你写一个程序,对于输入的某一个日期,输出1-7中某个数值,表示星期一到星期天中某一天(其中1为星期 一)。由于py是个熊孩子,他可能会说出一个不合法的日期,所以你还需要进行日期合法性判断,非法日期输出-1。Input输入包含多组数据。每行包括三个整数y(2000<=y<=9999), m, d。输入数据以0 0 0结束。Output每组数据输出一行,每行包括一个整数。1表示星期一,7表示星期日,等等,若数据非法,则输出-1。0 0 0不需输出7602. calen 阅读全文
posted @ 2013-02-27 15:00 Joyee 阅读(456) 评论(0) 推荐(0)
摘要:DescriptionHengheng is a math nerd. Today he invents a new kind of numbers so called H number. These numbers satisfy that each digit is either the sum or the difference of the adjacent digits. Notice that the first and the last digit are not constrained, except that the first digit is not zero (i.e. 阅读全文
posted @ 2013-02-09 14:42 Joyee 阅读(315) 评论(0) 推荐(0)
摘要:DescriptionFarmer John has scattered treats for Bessie at special places in the pasture. Since everyone knows that smart cows make tasty milk, FJ has placed the treats at locations that require Bessie to think. He has given her two numbers, P and Q (1 <= P <= 6,000; 1 <= Q <= 6,000), and 阅读全文
posted @ 2013-02-09 14:16 Joyee 阅读(827) 评论(0) 推荐(0)
摘要:DescriptionBessie wants some toys. She's been saving her allowance for years, and has an incredibly huge stash. However, she is quite frugal and wants to get the best value for her cash. In fact, she has decided only to buy exactly three different toys of the N (3 <= N <= 25,000) offered a 阅读全文
posted @ 2013-02-06 01:28 Joyee 阅读(346) 评论(0) 推荐(0)
摘要:DescriptionWrite a program that reads in the radius and length of a cylinder and computes volume using the following formulas:area = radius * radius * PIvolume = area * lengthPI = 3.14159 InputOne line contains num1, num2 (both in double) represent the radius and length of a cyliner. OutputThe volum 阅读全文
posted @ 2013-02-06 01:05 Joyee 阅读(376) 评论(0) 推荐(0)
摘要:Description校歌手大奖赛中每个评委会给每个参赛选手打分,请用类描述每个选手的被评委的评分。选手得分规则为去掉一个最高分和一个最低分,然后计算平均得分,请编程输出某选手的得分。Input输入数据有多组,第一行为数据组数T每组数据第一行两个正整数 n m (3 <= n,m <= 100),表示有 n 个 评 委 , m个选手。接下来 n 行,每行 m 个正整数。每行表示一个评委给 m 个选手的分数,分数为[0,100]的整数。Output请将结果输出对于每组输入数据输出 m 行,每行表示一个选手的得分,结果保留 2 位小数。水题,二维数组存储,一维数组记录最高最低分,最后统 阅读全文
posted @ 2013-02-04 08:00 Joyee 阅读(621) 评论(0) 推荐(0)
摘要:DescriptionZSUQ Messenger is similar with Tencent QQ. Each user will make a nickname for itself. Different users can have identical nickname. Some common ones, such as “Tom”, “Marry”, “Kate”, are frequently used. In a recent survey, the ZSUQ Company was astonished to find that there are no more than 阅读全文
posted @ 2013-02-04 07:58 Joyee 阅读(602) 评论(0) 推荐(0)
摘要:DescriptionTrung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 < N < 10000) . After that, he counts the number of times each digit (0 to 9) appears in the sequence. For example, with N = 13 , the 阅读全文
posted @ 2013-01-30 15:02 Joyee 阅读(578) 评论(1) 推荐(0)
摘要:Description You: What's the score? Did I miss much? Me: It's 2-1 for elAhli and the second half just started. The first half was quite boring. You: Who scored first? elAhli or ezZamalek? Me: What difference does it make? You: Big difference! I can predict the outcome of the match if I knew t 阅读全文
posted @ 2013-01-30 14:51 Joyee 阅读(517) 评论(0) 推荐(0)
摘要:DescriptionAn abundant number is a positive integer n for which Sigma(n) – 2n > 0, Where Sigma(n) is defined as the sum of all the divisors of n. And the quantity Sigma(n) – 2n is called abundance.Given the range of n, you should find out the maximum abundance value that can be reached. For examp 阅读全文
posted @ 2013-01-30 03:32 Joyee 阅读(371) 评论(0) 推荐(0)
摘要:DescriptionIn sixth grade, students are presented with different ways to calculate the Least Common Multiple (LCM) and the Greatest Common Factor (GCF) of two integers. The LCM of two integers a and b is the smallest positive integer that is a multiple of both a and b . The GCF of two non-zero integ 阅读全文
posted @ 2013-01-30 03:19 Joyee 阅读(336) 评论(0) 推荐(0)
摘要:DescriptionWell, how do you feel about mobile phone? Your answer would probably be something like that “It’s so convenient and benefits people a lot”.... 阅读全文
posted @ 2013-01-26 03:22 Joyee 阅读(954) 评论(1) 推荐(0)
摘要:DescriptionLong long ago, there was a super computer that could deal with VeryLongIntegers(no VeryLongInteger will be negative). Do you know how this computer stores the VeryLongIntegers? This computer has a set of n positive integers: b1,b2,...,bn, which is called a basis for the computer.The basis 阅读全文
posted @ 2013-01-25 19:54 Joyee 阅读(591) 评论(1) 推荐(0)
摘要:Description The columnar encryption scheme scrambles the letters in a message (or plaintext) using a keyword as illustrated in the following example: Suppose BATBOY is the keyword and our message is MEET ME BY THE OLD OAK TREE. Since the keyword has 6 letters, we write the message (ignoring spacing 阅读全文
posted @ 2013-01-22 12:31 Joyee 阅读(709) 评论(0) 推荐(0)
摘要:DescriptionThe rabbits have powerful reproduction ability. One pair of adult rabbits can give birth to one pair of kid rabbits every month. And after ... 阅读全文
posted @ 2013-01-22 10:33 Joyee 阅读(847) 评论(0) 推荐(0)
摘要:Description歌手The Pancakes到幼儿园跟小朋友玩耍,她到达的时候小朋友们已经争着积木玩了。小朋友都想要更多的积木砌一个自己喜欢的图形,砌完就可以和The Pancakes合照。同时,The Pancakes手上还有一些积木,她可以把手上的这些积木全部给一个小朋友,然后等该小朋友砌完后就可以收回所发的积木和该小朋友原先手上的积木。但她不知道能否让所有的小朋友都和她合照,聪明的你可以帮助她吗?Input输入包含多个数据。每个数据的第一行是两个正整数n和s,1≤n≤10000,1≤s≤1000000,表示一共有n位小朋友,The Pancakes手上有s块积木。以下有n行,每行有 阅读全文
posted @ 2013-01-19 16:02 Joyee 阅读(531) 评论(0) 推荐(0)