Volume 1. String(uva)
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <fstream> using namespace std;
int n;
char s1[], s2[];
int pr1, pr2, pl1, pl2;
int main()
{
//ifstream cin("test.txt");
int i;
cin>>n;
cin.get();
while (n--)
{
cin.getline(s1, );
cin.getline(s2, );
for (i = ; s1[i] != '<'; i++)
cout<<s1[i];
pl1 = i;
for (i++; s1[i] != '>'; i++)
cout<<s1[i];
pr1 = i;
for (i++; s1[i] != '<'; i++)
cout<<s1[i];
pl2 = i;
for (i++; s1[i] != '>'; i++)
cout<<s1[i];
pr2 = i;
for (i++; s1[i]; i++)
cout<<s1[i];
cout<<endl;
for (i = ; s2[i] != '.'; i++)
cout<<s2[i];
for (i = pl2 + ; i < pr2; i++)
cout<<s1[i];
for (i = pr1 + ; i < pl2; i++)
cout<<s1[i];
for (i = pl1 + ; i < pr1; i++)
cout<<s1[i];
for (i = pr2 + ; s1[i]; i++)
cout<<s1[i];
cout<<endl; }
return ;
}
537 - Artificial Intelligence?
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <fstream> using namespace std;
int n;
string s;
char res[][];
int main()
{
//ifstream cin("test.txt");
double U, I, P, scale;
bool fu, fi, fp;
cin>>n;
int k = , i, j, p;
cin.get();
while (n--)
{
fu = fi = fp = false;
p = ;
cout<<"Problem #"<<k++<<endl;
getline(cin, s, '\n');
for (i = ; s[i]; i++)
{
//if (i > 0 && s[i] == '=' &&(s[i - 1] == 'P' || s[i - 1] == 'I' || s[i - 1] == 'U'))
if (s[i] == '=')
{
for (i--, j = ; s[i] != 'V' && s[i] != 'A' && s[i] != 'W'; i++, j++)
res[p][j] = s[i];
res[p][j] = '\0';
p++;
}
}
for (i = ; i < ; i++)
{
int len = strlen(res[i]) - ;
scale = ;
if (!isdigit(res[i][len]))
{
if (res[i][len] == 'k')
scale = ;
else
if (res[i][len] == 'M')
scale = ;
else
scale = 0.001;
res[i][len] = '\0';
}
double tmp = atof(&res[i][]) * scale;
if (res[i][] == 'I')
{
fi = true;
I = tmp;
}
else
if (res[i][] == 'U')
{
fu = true;
U = tmp;
}
else
{
fp = true;
P = tmp;
}
}
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision();
if (fu && fi)
{
cout<<"P="<<U * I<<"W"<<endl;
}
else
if (fu && fp)
{
cout<<"I="<<P / U<<"A"<<endl;
}
else
{
cout<<"U="<<P / I<<"V"<<endl;
}
cout<<endl;
}
return ;
}
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <fstream> using namespace std;
int k, e;
string words[];
string ex[];
int numex[]; bool cmp(const string str)
{
for (int i = ; i < k; i++)
if (str == words[i])
return true;
return false;
}
void calc()
{
string tmp;
int i, j, p, kmax = ;
memset(numex, , sizeof(numex));
for (i = ; i < e; i++)
{
j = ;
while (ex[i][j])
{
if (!isalpha(ex[i][j]))
{
j++;
continue;
}
tmp.clear();
while (isalpha(ex[i][j]))
{
tmp +=(ex[i][j++] | );
}
if (cmp(tmp))
{
numex[i]++;
}
}
if (numex[i] > kmax)
kmax = numex[i];
}
for (i = ; i < e; i++)
if (numex[i] == kmax)
cout<<ex[i]<<endl;
cout<<endl;
}
int main()
{
ifstream cin("test.txt");
int i, j, t = ;
while (cin>>k>>e)
{
cin.ignore();
for (i = ; i < k; i++)
getline(cin, words[i]);
for (i = ; i < e; i++)
getline(cin, ex[i]);
cout<<"Excuse Set #"<<t++<<endl;
calc();
}
return ;
}
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <fstream>
#include <cmath> using namespace std;
string str;
int main()
{
//ifstream cin("test.txt");
int s, p, i;
getline(cin, str);
while (getline(cin, str), str[] != '_')
{
s = p = ;
for (i = ; i > ; i--)
{
if (str[i] == '.')
continue;
if (str[i] == 'o')
s += pow(, p);
p++;
}
cout<<(char)s;
}
return ;
}
10815 - Andy's First Dictionary
#include <iostream>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
class cmp
{
public:
bool operator()(const string s1, const string s2)
{
return s1 < s2;
}
}; set<string, cmp> s;
int main()
{
freopen("test.txt", "r", stdin);
string tmp;
char ch = ;
while (ch != EOF)
{
ch = getchar();
if (!isalpha(ch))
continue;
tmp.clear();
while (true)
{
tmp += (ch | );
ch = getchar();
if (!isalpha(ch))
break;
}
s.insert(tmp);
}
for (set<string>::iterator it = s.begin(); it != s.end(); it++)
cout<<*it<<endl;
return ;
}
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
using namespace std;
string set[];
bool cmp(const string s1, const string s2)
{
int i = ;
while (s1[i] && s2[i])
{
if (s1[i] != s2[i])
break;
i++;
}
if (!s1[i] || !s2[i])
return true;
return false;
}
int main()
{
//ifstream cin("test.in");
int n, i, j, t = ;
while (getline(cin, set[]))
{
cout<<"Set "<<t++<<" is ";
n = ;
while (getline(cin, set[n]), set[n][] != '')
n++;
for (i = ; i < n - ; i++)
{
for (j = i + ; j < n; j++)
{
if (cmp(set[i], set[j]))
break;
}
if (j < n)
break;
}
if (i < n - )
cout<<"not ";
cout<<"immediately decodable"<<endl;
}
return ;
}
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#define N 15
using namespace std;
string f[N], re[N];
string edit;
int n, q;
bool cmp(int p)
{
int i, j, k, m;
for (i = q; i < n; i++)
{
for (m = p; edit[m]; m++)
{
for (j = , k = m; f[i][j] && edit[k]; j++, k++)
{
if (edit[k] != f[i][j])
break;
}
if (!f[i][j])//替换
{
edit.replace(edit.begin() + m, edit.begin() + k, re[i]);
if (i != q)
q = i;
return true;
}
} }
return false;
}
int main()
{
int i, j;
while (cin>>n, n)
{
cin.get();
q = ;
for (i = ; i < n; i++)
{
getline(cin, f[i]);
getline(cin, re[i]);
}
getline(cin, edit);
for (i = ; edit[i]; i++)
{
if (cmp(i))
i = -;
}
cout<<edit<<endl;
}
}
Volume 1. String(uva)的更多相关文章
- DNA Consensus String UVA - 1368
题目链接:https://vjudge.net/problem/UVA-1368 题意:给出一组字符串,求出一组串,使与其他不同的点的和最小 题解:这个题就是一个点一个点求,利用桶排序,求出最多点数目 ...
- Dockerfile Volume指令与docker -v的区别
在学习Dockerfile的过程中有个VOLUME命令,很多教程或书中说的是用来定义匿名卷的,其作用如下: 容器运行时应该尽量保持容器存储层不发生写操作,对于数据库类需要保存动态数据的应用,其数据库文 ...
- docker -v 和Dockerfile 中VOLUME 区别
在学习Dockerfile的过程中有个VOLUME命令,很多教程或书中说的是用来定义匿名卷的,其作用如下: 容器运行时应该尽量保持容器存储层不发生写操作,对于数据库类需要保存动态数据的应用,其数据库文 ...
- 我在GNU/Linux下使用的桌面环境工具组合
为了使GNU/Linux桌面环境下加载的程序较少以节省内存资源和提高启动时间,我目前并不使用重量级的桌面环境KDE和Gnome,甚至连登录窗界面gdm或xdm都不用,而是直接启动到控制台,登录后调用s ...
- 5、Docker容器网络
使用Linux进行IP层网络管理的指 http://linux-ip.net/html/ # yum install iproute http://linux-ip.net/html/tool ...
- docker 容器 详解
docker run ## 创建一个新容器 [root@localhost ~]# docker run --help Usage: docker run [OPTIONS] IMAGE [COMM ...
- Docker: docker container常用命令实战
容器管理,容器常用选项 选项 描述 -i, –interactive 交互式 -t, –tty 分配一个伪终端 -d, –detach 运行容器到后台 -e, –env 设置环境变量 -p, –pub ...
- sqlchemy self made
# -*- coding: utf-8 -*- from sqlalchemy import create_engine, Column, String, Integer, ForeignKey, T ...
- c# speech 文本转语言
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
随机推荐
- 洛谷 P1606 [USACO07FEB]荷叶塘Lilypad Pond【spfa】
和bzoj同名题不一样! 起点和水点向花费一个荷花能到的第一个点连一条边权为1的有向边,然后跑计数spfa即可 #include<iostream> #include<cstdio& ...
- Visual Studio 2015 个版本下载
Visual Studio 2015是一个基本完整的开发工具集,它包括了整个软件生命周期中所需要的大部分工具,如UML工具.代码管控工具.集成开发环境(IDE)等等.所写的目标代码适用于微软支持的所有 ...
- win7下硬盘安装Windows
win7下硬盘安装Windows: 1.下载 Windows 7 ISO镜像,用虚拟光驱拷贝至非C盘(如d:\win7)2.开机按F8 - 修复系统 - 选择最后一项命令修复 - 在命令框输入 d:\ ...
- spring boot 项目发布运行
1. maven install 发布jar包 2. java -jar webservice.jar 启动jar包
- SQL 初级教程学习(六)
1.创建视图 CREATE VIEW [Current Product List] ASSELECT ProductID,ProductNameFROM ProductsWHERE Discontin ...
- [ZOJ1140]Courses 课程
Description 给出课程的总数P(1<=p<100),学生的总数N(1<=N<=300) 每个学生可能选了一门课程,也有可能多门,也有可能没有. 要求选出P个学生来组成 ...
- 使用Apache Commons IO组件读取大文件
Apache Commons IO读取文件代码如下: Files.readLines(new File(path), Charsets.UTF_8); FileUtils.readLines(new ...
- 鼠标适配器Adapter
先来看看概念: 现在我们要写一个这样的东西,就是一个窗口,然后鼠标点一下就有一个小圆点,like this: 来我们来看代码: import java.awt.*; import java.util. ...
- bootstrap框架栅格系统使用
使用的前端框架 bootstrap框架 Bootstrap是一个响应式的框架 我们在使用的时候主要使用的是它的网格系统, 1.bootstrap布局 布局容器:.container(用于固定宽度并支 ...
- 最新最强短视频SDK——来自RDSDK.COM
北京锐动天地信息技术有限公司成立于2007年9月.多年来一直专注于音视频领域核心技术的研发, 拥有Windows.iOS.Android全平台自主知识产权的领先技术产品. 2011年获得新浪战略投资, ...