看完发现文档缺页。。。。。。

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 ;
}
4.4.7  编码
给定一个只包含“A”~“Z”的字符串,我们使用下面的方法给它编码: (1)将子字符串中的 k 个相同字符写成“kX ”,X 是子串中的字符。 (2)如果子串的长度是 1,那么“1”要忽略。
输入描述
第一行包含一个正整数 N(1≤N≤100),代表测试案例的个数。下面 N 行包含 N 个 字符串。每个字符串仅包含“A”~“Z”,且字符串的长度小于 100。
输出描述
对于每个测试案例,输出它的编码在单独一行上。
输入描述
2
ABC
ABBCCC
输出描述
ABC
A2B3C
#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详解》解题报告的更多相关文章

  1. 《MIT 6.828 Homework 2: Shell》解题报告

    Homework 2的网站链接:MIT 6.828 Homework 2: shell 题目 下载sh.c文件,在文件中添加相应代码,以支持以下关于shell的功能: 实现简单shell命令,比如ca ...

  2. 《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 ...

  3. 《MIT 6.828 Lab1: Booting a PC》实验报告

    <MIT 6.828 Lab1: Booting a PC>实验报告 本实验的网站链接见:Lab 1: Booting a PC. 实验内容 熟悉x86汇编语言.QEMU x86仿真器.P ...

  4. 《MIT 6.828 Lab 1 Exercise 12》实验报告

    本实验的网站链接:MIT 6.828 Lab 1 Exercise 12. 题目 Exercise 12. Modify your stack backtrace function to displa ...

  5. 《MIT 6.828 Lab 1 Exercise 11》实验报告

    本实验的网站链接:MIT 6.828 Lab 1 Exercise 11. 题目 The above exercise should give you the information you need ...

  6. 《MIT 6.828 Lab 1 Exercise 10》实验报告

    本实验的网站链接:MIT 6.828 Lab 1 Exercise 10. 题目 Exercise 10. To become familiar with the C calling conventi ...

  7. 《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 ...

  8. 《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 ...

  9. 《MIT 6.828 Lab 1 Exercise 4》实验报告

    本实验链接:mit 6.828 lab1 Exercise 4. 题目 Exercise 4. Read about programming with pointers in C. The best ...

  10. 《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 ...

随机推荐

  1. Browsersync 简介 and 使用

    简介 省时的浏览器同步测试工具,Browsersync能让浏览器实时.快速响应您的文件更改(html.js.css.sass.less等)并自动刷新页面. 曾经我们每改一次的代码,都需要手动去刷新一次 ...

  2. Mybatis——Spring整合

    一.引入依赖 Spring的相关jar包 mybatis-3.4.1.jar mybatis-spring-1.3.0.jar mysql-connector-java-5.1.37-bin.jar ...

  3. OVS的初始配置

    1.去掉bridge模块,为下面用OVS的模块奠定基础 rmmod bridge .insmod datapath/linux/openvswitch_mod.ko .insmod datapath/ ...

  4. 浅析C语言中assert的用法(转)

    原文地址:http://www.jb51.net/article/39685.htm 以下是对C语言中assert的使用方法进行了介绍,需要的朋友可以参考下. assert宏的原型定义在<ass ...

  5. LightOJ 1065 Island of Survival (概率DP?)

    题意:有 t 只老虎,d只鹿,还有一个人,每天都要有两个生物碰面,1.老虎和老虎碰面,两只老虎就会同归于尽 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉对方 3.人和鹿碰面,人可以选择杀或者不杀该鹿4. ...

  6. Java集合框架---重构设计

    面向接口编程: 接口类型 变量 =new 实现类(); List  list=new ArrayList(); --------------------------------------- List ...

  7. Nginx禁止直接通过IP地址访问网站

    介绍下在nginx服务器禁止直接通过IP地址访问网站的方法,以避免别人恶意指向自己的IP,有需要的朋友参考下. 有时会遇到很多的恶意IP攻击,在Nginx下可以禁止IP访问. Nginx的默认虚拟主机 ...

  8. 最近的一些零碎知识点,jquery遍历

    1.使按钮无法点击 $(“#btn”).attr("disable",true); 2.返回上一个页面 history.back(-1); 3.$(this).siblings() ...

  9. [bash] 显示配色

    #/bin/bash for STYLE in 0 1 2 3 4 5 6 7; do for FG in 30 31 32 33 34 35 36 37; do for BG in 40 41 42 ...

  10. Java 根据Date计算年龄