自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(88)
  • 问答 (16)
  • 收藏
  • 关注

原创 015:编程填空:矩形排序

描述给定一系列边长已知的矩形,输出对矩形进行两种排序的结果。在第一种排序中,先按矩形的面积从大到小排序;若两个矩形的面积相同,则周长大的排在前。在第二种排序中,先按矩形的周长从小到大排序;若两个矩形的周长相同,则面积小的排在前。#include <iostream>#include <set>using namespace std;// 在此处补充你的代码int main() { multiset<Rectangle> m1; mu...

2021-09-05 17:07:42 1036

原创 014:编程填空:又见模板

描述填写代码,按要求输出结果:#include <iostream>#include <string>using namespace std;// 在此处补充你的代码int main() { int t; cin >> t; while( t -- ) { int b1[10]; for(int i = 0;i < 10; ++i) cin...

2021-09-05 14:51:25 340

原创 013:编程填空:三生三世

描述近年来,国内电视剧吸引了越来越多的关注;有的以当红的演员阵容而吸引观众,比如《三生三世十里桃花》(Life After Life,Blooms Over Blooms);有的以贴近时代的剧情而备受关注,比如《人民的名义》(In the Name of People);有的则以精湛的演技赢得观众的喜欢,比如《大明王朝:1566》(Ming Dynasty: 1566)。你的任务是根据电视剧的不同属性(演员、剧情和演技)对电视剧进行排行。#include<iostream>#in.

2021-09-05 14:23:20 334

原创 012:编程填空:Printer

描述完成以下程序,使得输入的整数x,以及若干正整数,将大于x的正整数输出;然后输入若干字符串,将字符串长度大于x的字符串输出#include<iostream>#include<algorithm>#include<vector>#include<bitset>using namespace std;class Printer{// 在此处补充你的代码int main(){ int t; cin >>.

2021-09-05 11:27:12 318

原创 011:编程填空:前K大的偶数

描述输入n个整数,输出整数数列中大小排名前k的偶数#include <algorithm>#include <iostream>#include <stack>#include <queue>#include <vector>#include <cstring>#include <cstdlib>#include <string>#include <map>#incl..

2021-09-05 10:55:40 114

原创 010:编程填空:回调函数

描述输入x1 x2 x3 x4 x5 ,输出y = x5^5 + x4^4 + x3^3 + x2^2 + x1^1 + 1的y的值#include <algorithm>#include <iostream>#include <stack>#include <queue>#include <vector>#include <cstring>#include <cstdlib>#include &l.

2021-09-05 09:24:29 143

原创 009:编程填空:简单的对象

描述程序填空,使得程序输出:2110#include <iostream>using namespace std;class A{ static int num;public: A(){num+=1;} void func() { cout<< num <<endl; }// 在此处补充你的代码};int A::num=1;int main(){ A a1; const A a2 = a1; A &am.

2021-09-05 09:04:37 279

原创 008:编程填空:还是Fun和Do

描述填写代码,使输出结果为A::FunB::DoC::FunC::DoA::FunB::Do#include <iostream> using namespace std;class A { public: virtual void Fun() { cout << "A::Fun" << endl; }; virtual void Do() { cout << "A::Do" <<.

2021-09-05 08:38:01 249

原创 007:编程填空:按要求输出

描述下列程序的输出为"10 13 18 15 17 12 16 19",请补充代码#include <iterator>#include <vector>#include <map>#include <set>#include <queue>#include <algorithm>#include <stack>#include <iostream>#include <s...

2021-09-04 18:03:58 265

原创 006:编程填空:去除重复元素排序

描述程序填空,使其按要求输出#include <iterator>#include <vector>#include <map>#include <set>#include <queue>#include <algorithm>#include <stack>#include <iostream>#include <set>using namespace std;in.

2021-09-04 17:45:09 244

原创 005:编程填空:又是MyClass

描述补充下列代码,使得程序能够按要求输出#include <iostream>#include <cstring> #include <vector>#include <cstdio> using namespace std;// 在此处补充你的代码int a[40];int main(int argc, char** argv) { int t; scanf("%d",&t); while ( t -- ) .

2021-09-04 17:10:27 142

原创 004:编程填空:MyClass

描述补充下列代码,使得程序的输出为:A:3A:15B:53155#include <iostream>using namespace std;class CMyClassA { int val;public: CMyClassA(int); void virtual print();};CMyClassA::CMyClassA(int arg) { val = arg; printf("A:%d\n", val);}void CMyClassA::.

2021-09-04 16:29:24 309

原创 003:编程填空:简单的计算

描述补充代码,使程序按要求输出#include <iostream>using namespace std;template <class T>class Add{public:// 在此处补充你的代码};int main(){ double f; int n; while( cin >> f >> n) { Add<double> a1(f); Add<int> a2(n)...

2021-09-04 16:03:31 263

原创 002:编程填空:统计动物数量

描述代码填空,使得程序能够自动统计当前各种动物的数量#include <iostream>using namespace std;// 在此处补充你的代码void print() { cout << Animal::number << " animals in the zoo, " << Dog::number << " of them are dogs, " << Cat::number << .

2021-09-04 15:52:41 205

原创 001:编程填空:二进制输出

描述给出一个int表示范围内的正整数x,输出其二进制表示。一共要输出31位,不足处要补0。#include <iostream>#include <string>using namespace std;string dec2bin(int x){// 在此处补充你的代码}int main(){ int n; cin >> n; while(n--) { int x; cin >> x; cout <&lt.

2021-09-04 15:17:36 189

原创 007:Aggressive cows

描述Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000).His C (2 <= C <= N) cows don't like this barn layout and become.

2021-08-30 23:00:05 89

原创 006:简单的整数划分问题

描述将正整数n 表示成一系列正整数之和,n=n1+n2+…+nk, 其中n1>=n2>=…>=nk>=1 ,k>=1 。正整数n 的这种表示称为正整数n 的划分。正整数n 的不同的划分个数称为正整数n 的划分数。输入标准的输入包含若干组测试数据。每组测试数据是一个整数N(0 < N <= 50)。输出对于每组测试数据,输出N的划分数。样例输入5样例输出7提示5, 4+1, 3+2, 3+1+1, 2+2+1, 2+1+1+1, 1+1+1.

2021-08-30 16:35:47 484

原创 005:Boolean Expressions

描述The objective of the program you are going to produce is to evaluate boolean expressions as the one shown next:Expression: ( V | V ) & F & ( F | V )where V is for True, and F is for False. The expressions may include the following opera...

2021-08-30 15:54:56 353

原创 004:2的幂次方表示

描述任何一个正整数都可以用2的幂次方表示。例如:137=27+23+20同时约定方次用括号来表示,即ab可表示为a(b)。由此可知,137可表示为:2(7)+2(3)+2(0)进一步:7=22+2+20(21用2表示)3=2+20所以最后137可表示为:2(2(2)+2+2(0))+2(2+2(0))+2(0)又如:1315=210+28+25+2+1所以1315最后可表示为:2(2(2+2(0))+2...

2021-08-29 20:31:36 162

原创 003:全排列

描述给定一个由不同的小写字母组成的字符串,输出这个字符串的所有全排列。 我们假设对于小写字母有'a' < 'b' < ... < 'y' < 'z',而且给定的字符串中的字母已经按照从小到大的顺序排列。输入输入只有一行,是一个由不同的小写字母组成的字符串,已知字符串的长度在1到6之间。输出输出这个字符串的所有排列方式,每行一个排列。要求字母序比较小的排列在前面。字母序如下定义:已知S = s1s2...sk, T = t1t2...tk,则S < T...

2021-08-29 18:25:01 168

原创 002:拨钟问题

描述有9个时钟,排成一个3*3的矩阵。|-------| |-------| |-------|| | | | | | ||---O | |---O | | O || | | | | ||-------| |-------| |-------| A B C |-------| |.

2021-08-29 12:23:46 260

原创 001:特殊密码锁

总时间限制: 1000ms 内存限制: 1024kB描述有一种特殊的二进制密码锁,由n个相连的按钮组成(n<30),按钮有凹/凸两种状态,用手按按钮会改变其状态。然而让人头疼的是,当你按一个按钮时,跟它相邻的两个按钮状态也会反转。当然,如果你按的是最左或者最右边的按钮,该按钮只会影响到跟它相邻的一个按钮。当前密码锁状态已知,需要解决的问题是,你至少需要按多少次按钮,才能将密码锁转变为所期望的目标状态。输入两行,给出两个由0、1组成的等长字符串,表示当前/目标密码锁状态,其中0代表凹.

2021-08-29 10:08:16 197 1

原创 043:冷血格斗场

描述为了迎接08年的奥运会,让大家更加了解各种格斗运动,facer新开了一家冷血格斗场。格斗场实行会员制,但是新来的会员不需要交入会费,而只要同一名老会员打一场表演赛,证明自己的实力。我们假设格斗的实力可以用一个非负整数表示,称为实力值,两人的实力值可以相同。另外,每个人都有一个唯一的id,也是一个正整数。为了使得比赛更好看,每一个新队员都会选择与他实力最为接近的人比赛,即比赛双方的实力值之差的绝对值越小越好,如果有多个人的实力值与他差别相同,则他会选择id最小的那个。不幸的是,Facer一不小.

2021-08-27 17:45:37 128

原创 042:热血格斗场

描述为了迎接08年的奥运会,让大家更加了解各种格斗运动,facer新开了一家热血格斗场。格斗场实行会员制,但是新来的会员不需要交入会费,而只要同一名老会员打一场表演赛,证明自己的实力。我们假设格斗的实力可以用一个正整数表示,成为实力值。另外,每个人都有一个唯一的id,也是一个正整数。为了使得比赛更好看,每一个新队员都会选择与他实力最为接近的人比赛,即比赛双方的实力值之差的绝对值越小越好,如果有两个人的实力值与他差别相同,则他会选择比他弱的那个(显然,虐人必被虐好)。不幸的是,Facer一不小心把.

2021-08-27 16:29:31 202

原创 041:Set

描述现有一整数集(允许有重复元素),初始为空。我们定义如下操作:add x 把x加入集合del x 把集合中所有与x相等的元素删除ask x 对集合中元素x的情况询问对每种操作,我们要求进行如下输出。add 输出操作后集合中x的个数del 输出操作前集合中x的个数ask 先输出0或1表示x是否曾被加入集合(0表示不曾加入),再输出当前集合中x的个数,中间用空格格开。输入第一行是一个整数n,表示命令数。0<=n<=100000。后面n行命令,如Description中所述。.

2021-08-27 14:22:29 198

原创 040:List

描述写一个程序完成以下命令:new id ——新建一个指定编号为id的序列(id<10000)add id num——向编号为id的序列加入整数nummerge id1 id2——合并序列id1和id2中的数,并将id2清空unique id——去掉序列id中重复的元素out id ——从小到大输出编号为id的序列中的元素,以空格隔开输入第一行一个数n,表示有多少个命令( n<=200000)。以后n行每行一个命令。输出按题目要求输出。样例输入16new 1new 2.

2021-08-26 23:06:39 162

原创 039:我自己的 ostream_iterator

描述程序填空输出指定结果#include <iostream>#include <list>#include <string>using namespace std;template <class T1,class T2>void Copy(T1 s,T1 e, T2 x){ for(; s != e; ++s,++x) *x = *s;} template<class T>class myostream_it.

2021-08-26 22:39:36 412 1

原创 038:白给的list排序

描述程序填空,产生指定输出#include <cstdio>#include <iostream>#include <algorithm>#include <list>using namespace std;int main(){ double a[] = {1.2,3.4,9.8,7.3,2.6}; list<double> lst(a,a+5); lst.sort(// 在此处补充你的代码); for(li.

2021-08-26 22:04:57 638

原创 037:函数对象的过滤器

描述程序填空输出指定结果#include <iostream>#include <vector>using namespace std;struct A { int v; A() { } A(int n):v(n) { }; bool operator<(const A & a) const { return v < a.v; }};// 在此处补充你的代码template <class T>void Print.

2021-08-26 21:45:32 134

原创 036:很难蒙混过关的CArray3d三维数组模板类

描述实现一个三维数组模版CArray3D,可以用来生成元素为任意类型变量的三维数组,输出指定结果#include <iostream>#include <iomanip> #include <cstring>using namespace std;template <class T>class CArray3D{// 在此处补充你的代码};CArray3D<int> a(3,4,5);CArray3D<doubl.

2021-08-26 18:44:46 301

原创 035:按距离排序

描述程序填空,输出指定结果#include <iostream>#include <cmath>#include <algorithm>#include <string>using namespace std;template <class T1,class T2>struct Closer {// 在此处补充你的代码};int Distance1(int n1,int n2) { return abs(n1-n2);.

2021-08-26 17:23:30 189

原创 034:goodcopy

描述编写GoodCopy类模板,使得程序按指定方式输出#include <iostream>using namespace std;template <class T>struct GoodCopy {// 在此处补充你的代码};int a[200];int b[200];string c[200];string d[200];template <class T>void Print(T s,T e) { for(; s != e;.

2021-08-26 16:26:46 212

原创 033:排序,又见排序!

描述自己编写一个能对任何类型的数组进行排序的mysort函数模版。只能写一个mysort模板,不能写mysort函数!#include <iostream>using namespace std;bool Greater2(int n1,int n2) { return n1 > n2;}bool Greater1(int n1,int n2) { return n1 < n2;}bool Greater3(double d1,double d2){.

2021-08-26 15:55:40 143

原创 032:这个模板并不难

描述程序填空,输出指定结果#include <iostream>#include <string>#include <cstring>using namespace std;template <class T> class myclass {// 在此处补充你的代码~myclass( ) { delete [] p; } void Show() { for( int i = 0;i < size;i ++ ) { .

2021-08-24 22:20:37 179

原创 031:山寨版istream_iterator

描述模仿C++标准模板库istream_iterator用法,实现CMyistream_iterator使得程序按要求输出#include <iostream>#include <string>using namespace std;template <class T>class CMyistream_iterator{// 在此处补充你的代码};int main() { int t; cin >> t; while.

2021-08-24 21:40:34 437

原创 030:你真的搞清楚为啥 while(cin >> n) 能成立了吗?

描述读入两个整数,输出两个整数 ,直到碰到-1#include <iostream>using namespace std;class MyCin{// 在此处补充你的代码};int main(){ MyCin m; int n1,n2; while( m >> n1 >> n2) cout << n1 << " " << n2 << endl; re.

2021-08-24 20:47:24 306

原创 029:简单的Filter

描述编写Filter模板,使得程序产生指定输出 不得编写 Filter函数#include <iostream>#include <string>using namespace std;// 在此处补充你的代码bool LargerThan2(int n){ return n > 2;}bool LongerThan3(string s) { return s.length() > 3;}string as1[5] = {"Tom","M.

2021-08-24 20:10:26 196

原创 028:简单的foreach

描述编写MyForeach模板,使程序按要求输出 不得编写 MyForeach函数#include <iostream>#include <string>using namespace std;// 在此处补充你的代码void Print(string s){ cout << s;}void Inc(int & n){ ++ n;}string array[100];int a[100];int main() { int m,.

2021-08-24 19:36:23 224

原创 027:简单的SumArray

描述填写模板 PrintArray,使得程序输出结果是: TomJackMaryJohn 10 不得编写SumArray函数#include <iostream>#include <string>using namespace std;template <class T>T SumArray(// 在此处补充你的代码}int main() { string array[4] = { "Tom","Jack","Mary","John"}; cou.

2021-08-24 18:56:19 308

原创 026:编程填空:统计动物数量

描述代码填空,使得程序能够自动统计当前各种动物的数量#include <iostream>using namespace std;// 在此处补充你的代码void print() { cout << Animal::number << " animals in the zoo, " << Dog::number << " of them are dogs, " << Cat::number << " of t.

2021-08-24 14:21:05 239

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除