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 ...
随机推荐
- poj 2396 Budget【有上下界的网络流】
第一步:建立无源汇有上下界的网络模型 每行 i 作为一个点并连边(s, i, Ri, Ri),每列 j 作为一个点并连边(j, t, Cj, Cj),设 Uij, Lij 分别表示第 i 行第 j 列 ...
- spring-retry简单demo(附完整代码)
重试 最近项目要用到重试.开始想自己写,后来想用RetryTemplate,最后想到既然项目用了springboot,还是直接集成spring-retry把. 代码 Application packa ...
- Python测试工具——nose
1.nose 特点: a) 自动发现测试用例(包含[Tt]est文件以及文件包中包含test的函数) b) 以test开头的文件 c) 以test开头的 ...
- Bootstrap简介及安装使用
Bootstrap 简介 什么是 Bootstrap? Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的 ...
- Java Annontation(注解)详解
java中经常用到注解(Annontation),索性整理了下关于注解的相关知识点: 一.概念 Annontation是Java5开始引入的新特征,类似与.NET 中的attribute.中文名称一般 ...
- 移动端UI自动化Appium测试——Windows系统Appium环境配置
1.安装JDK,官网下载即可,这里用的1.8,环境变量配置 2.安装Android sdk,API >= 17,环境变量配置 3.安装Nodejs,官网http://nodejs.org/dow ...
- 初学Ajax
AJAX即“Asynchronous Javascript And XML”(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术. AJAX = 异步 JavaScript和 ...
- Caused by: javax.el.PropertyNotFoundException: Property 'product' not found on type java.lang.String
今天在JSP利用EL表达式取值报了 "javax.el.PropertyNotFoundException”,经过debug和打印将问题定位到这段代码: HTML应该是没啥问题,看提示在ja ...
- [BZOJ1005][HNOI2008]明明的烦恼 数学+prufer序列+高精度
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int N; ...
- 请大家帮我找一找bug —— 一个MySQL解析程序(JAVA实现)
周末两天我写了一个MySQLParser.写这个东西的目的是:公司的一个项目中需要对数据打版本号(每个表的每条记录要有一个版本号字段,这个字段需要由框架自动打上去,而不是由程序员来做). 所以,我写的 ...