《STL详解》解题报告
看完发现文档缺页。。。。。。
3.5 菲波那契数
vector<int> v;
v.push_back();
v.push_back();
for(int i = ;i < ;++i)
v.push_back(v[i - ] + v[i - ]);
3.14 01 串 排 序
3.14.1  链接地址 
http://acm.zjut.edu.cn/网上第 1204 题 
3.14.2  题目内容 
将 01 串首先按长度排序,长度相同时,按 1 的个数多少进行排序,1 的个数相同时再 按 ASCII 码值排序。 输入描述:输入数据中含有一些 01 串,01 串的长度不大于 256 个字符。 输出描述:重新排列 01 串的顺序,使得串按题目描述的方式排序。 输入样例 
 
10011111
00001101
1010101
1
0
1100 
 
输出样例 
 
0
1
1100
1010101
00001101
10011111
struct myComp
{
bool operator ()(const string &a, const string &b)
{
if(a.size() != b.size())
return a.size() < b.size();
int numa = count(a.begin(), a.end(), '');
int numb = count(b.begin(), b.end(), '');
if(numa != numb)
return numa < numb;
return a < b;
}
}; int main()
{
multiset<string, myComp> m;
string s;
for(int i = ;i < ;++i)
{
cin >> s;
m.insert(s);
}
multiset<string, myComp> :: iterator it;
for(it = m.begin();it != m.end();++it)
cout << *it << endl;
return ;
}
3.15 排列对称串
3.15.1  链接地址 
http://acm.zjut.edu.cn/网上第 1208 题
3.15.2  题目内容 
字符串有些是对称的,有些是不对称的,请将那些对称的字符串按从小到大的顺序输 出。字符串先以长度论大小,如果长度相同,再以 ASCII 码值为排序标准。 输入描述:输入数据中含有一些字符串(1≤串长≤256)。 输出描述:根据每个字符串,输出对称的那些串,并且要求按从小到大的顺序输出。 输入样例 
 
123321
123454321
123
321
sdfsdfd
121212
\\dd\\ 
 
输出样例 
 
123321
\\dd\\
123454321
bool myComp(string &a, string &b)
{
if(a.size() != b.size())
return a.size() < b.size();
return a < b;
} int main()
{
string s, t;
vector<string> vs;
int i, j;
for(i = ;i < ;++i)
{
cin >> s;
t = s;
reverse(t.begin(), t.end());//反转
if(t == s)
vs.push_back(s);
}
sort(vs.begin(), vs.end(), myComp);
for(i = ;i < ;++i)
cout << vs[i] << endl;
return ;
}
给定一个只包含“A”~“Z”的字符串,我们使用下面的方法给它编码: (1)将子字符串中的 k 个相同字符写成“kX ”,X 是子串中的字符。 (2)如果子串的长度是 1,那么“1”要忽略。
第一行包含一个正整数 N(1≤N≤100),代表测试案例的个数。下面 N 行包含 N 个 字符串。每个字符串仅包含“A”~“Z”,且字符串的长度小于 100。
输出描述
对于每个测试案例,输出它的编码在单独一行上。
输入描述
2
ABC
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <stack>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <list>
#include <bitset> using namespace std; typedef long long ll;
const int MAXN = ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ; int main()
{
string s;
int n;
cin >> n;
while(n--)
{
string p;
cin >> s;
int num = ;
for(int i = ;i < s.size();++i)
{
if(s[i] == s[i - ])
num++;
else
{
if(num != )
p += num + '';
p += s[i - ];
num = ;
}
}
p += num + '';
p += s[s.size() - ];
cout << p << endl;
}
return ;
}
《STL详解》解题报告的更多相关文章
- 《MIT 6.828 Homework 2: Shell》解题报告
		
Homework 2的网站链接:MIT 6.828 Homework 2: shell 题目 下载sh.c文件,在文件中添加相应代码,以支持以下关于shell的功能: 实现简单shell命令,比如ca ...
 - 《MIT 6.828 Homework 1: boot xv6》解题报告
		
本作业的网站链接:MIT 6.828 Homework 1: boot xv6 问题 Exercise: What is on the stack? While stopped at the abov ...
 - 《MIT 6.828 Lab1: Booting a PC》实验报告
		
<MIT 6.828 Lab1: Booting a PC>实验报告 本实验的网站链接见:Lab 1: Booting a PC. 实验内容 熟悉x86汇编语言.QEMU x86仿真器.P ...
 - 《MIT 6.828 Lab 1 Exercise 12》实验报告
		
本实验的网站链接:MIT 6.828 Lab 1 Exercise 12. 题目 Exercise 12. Modify your stack backtrace function to displa ...
 - 《MIT 6.828 Lab 1 Exercise 11》实验报告
		
本实验的网站链接:MIT 6.828 Lab 1 Exercise 11. 题目 The above exercise should give you the information you need ...
 - 《MIT 6.828 Lab 1 Exercise 10》实验报告
		
本实验的网站链接:MIT 6.828 Lab 1 Exercise 10. 题目 Exercise 10. To become familiar with the C calling conventi ...
 - 《MIT 6.828 Lab 1 Exercise 8》实验报告
		
本实验的网站链接:MIT 6.828 Lab 1 Exercise 8. 题目 Exercise 8. Read through kern/printf.c, lib/printfmt.c, and ...
 - 《MIT 6.828 Lab 1 Exercise 7》实验报告
		
本实验链接:mit 6.828 lab1 Exercise 7. 题目 Exercise 7. Use QEMU and GDB to trace into the JOS kernel and st ...
 - 《MIT 6.828 Lab 1 Exercise 4》实验报告
		
本实验链接:mit 6.828 lab1 Exercise 4. 题目 Exercise 4. Read about programming with pointers in C. The best ...
 - 《MIT 6.828 Lab 1 Exercise 3》实验报告
		
本实验的网站链接:mit 6.828 lab1 Exercise 3. 题目 Exercise 3. Take a look at the lab tools guide, especially th ...
 
随机推荐
- codefirst 关系处理
			
1.http://www.cnblogs.com/libingql/archive/2013/01/31/2888201.html 2.多对多 protected override void OnMo ...
 - 在slam_gmapping中使用Log数据创建地图
			
本文介绍使用机器人记录的tf变换和激光扫描数据来建立2D地图.并在ROS的图形化模拟环境rviz中通过重新回放记录的数据作为机器人真实传感器采集的输入,来观测地图动态创建过程. 1.ROS gmapp ...
 - eclipse——Maven创建JavaWeb工程
			
打包方式改为war 问题:webapp目录下缺少web.xml文件 先勾选掉Dynamic Web Services 点击Applay 再勾选上Dynamic Web Services ,目的是为了产 ...
 - linux下SVN服务器配置
			
SVN服务器配置 1. 安装svn服务 yum install subversion 2. 新建一个目录用于存储SVN所有文件 mkdir /home/svn 3. 创建项目 在上面创建的文件夹中为项 ...
 - POJ - 3984 迷宫问题 BFS求具体路径坐标
			
迷宫问题 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, ...
 - jQuery bind() live()
			
<script type="text/javascript"> $(document).ready(function () { /*$('.clickme').live ...
 - HTML <area> 标签区域map标签
			
1.距形:(左上角顶点坐标为(x1,y1),右下角顶点坐标为(x2,y2)) <area shape="rect" coords="x1,y1,x2,y2" ...
 - Arduino I2C + 数字式环境光传感器BH1750FVI
			
BH1750FVI是日本罗姆(ROHM)半导体生产的数字式环境光传感IC.其主要特性有: I2C数字接口,支持速率最大400Kbps 输出量为光照度(Illuminance) 测量范围1~65535 ...
 - c# 如何筛选datatable
			
对DataTable数据各种筛选 筛选一个DataTable的数据,赋值给另外一个DataTable 假设: 有2个DataTable:DataTable A.DataTable B. 要求: 筛选D ...
 - 《C#多线程编程实战》2.10 SpinWait
			
emmm 这个SpinWait 中文是自旋等待的意思. 所谓自旋,就是自己追自己影子,周伯通的左右手互博,不好听就是放屁自己追着玩,小狗转圈咬自己的尾巴 SpinWait是一个结构体,并不是一个类. ...