10361 - Automatic Poetry

#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 ;
}

409 - Excuses, Excuses!

#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 ;
}

10878 - Decode the tape

#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 ;
}

644 - Immediate Decodability

#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 ;
}

10115 - Automatic Editing

#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)的更多相关文章

  1. DNA Consensus String UVA - 1368

    题目链接:https://vjudge.net/problem/UVA-1368 题意:给出一组字符串,求出一组串,使与其他不同的点的和最小 题解:这个题就是一个点一个点求,利用桶排序,求出最多点数目 ...

  2. Dockerfile Volume指令与docker -v的区别

    在学习Dockerfile的过程中有个VOLUME命令,很多教程或书中说的是用来定义匿名卷的,其作用如下: 容器运行时应该尽量保持容器存储层不发生写操作,对于数据库类需要保存动态数据的应用,其数据库文 ...

  3. docker -v 和Dockerfile 中VOLUME 区别

    在学习Dockerfile的过程中有个VOLUME命令,很多教程或书中说的是用来定义匿名卷的,其作用如下: 容器运行时应该尽量保持容器存储层不发生写操作,对于数据库类需要保存动态数据的应用,其数据库文 ...

  4. 我在GNU/Linux下使用的桌面环境工具组合

    为了使GNU/Linux桌面环境下加载的程序较少以节省内存资源和提高启动时间,我目前并不使用重量级的桌面环境KDE和Gnome,甚至连登录窗界面gdm或xdm都不用,而是直接启动到控制台,登录后调用s ...

  5. 5、Docker容器网络

    使用Linux进行IP层网络管理的指     http://linux-ip.net/html/ # yum install iproute http://linux-ip.net/html/tool ...

  6. docker 容器 详解

    docker run  ## 创建一个新容器 [root@localhost ~]# docker run --help Usage: docker run [OPTIONS] IMAGE [COMM ...

  7. Docker: docker container常用命令实战

    容器管理,容器常用选项 选项 描述 -i, –interactive 交互式 -t, –tty 分配一个伪终端 -d, –detach 运行容器到后台 -e, –env 设置环境变量 -p, –pub ...

  8. sqlchemy self made

    # -*- coding: utf-8 -*- from sqlalchemy import create_engine, Column, String, Integer, ForeignKey, T ...

  9. c# speech 文本转语言

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

随机推荐

  1. bzoj 3308: 九月的咖啡店【最大费用最大流】

    费用流里spfa最后的判断要写成dis[t]>=0而不是dis[t]!=-inf否则会WAWAWA-- #include<iostream> #include<cstdio&g ...

  2. 洛谷 P2774 方格取数问题【最小割】

    因为都是正整数,所以当然取得越多越好.先把所有点权加起来,黑白染色后,s向所有黑点连流量为点权的边,所有白点向t连流量为点权的边,然后黑点向相邻的四个白点连流量为inf的边,表示不可割,这样一来,对于 ...

  3. $Edmonds-Karp$[网络流]

    \(原题戳这里\) >最大流最小割定理$(Maximum Flow, Minimum Cut Theorem): $ 网络的最大流等于最小割 具体的证明分三部分 1.任意一个流都小于等于任意一个 ...

  4. linux 正确的关机方法

    正确的关机方法 1. 查看系统的使用状态 执行who命令或者netstat -a ,要查看后台执行的程序可以执行“ps -aux” 2. 正确的关机命令 1)将内存中数据同步写入磁盘:sync,这个命 ...

  5. ueditor 编辑

    1.net  config.json imageUrlPrefix

  6. 【react native】有关入坑3个月RN的心路历程

    由于一些原因,笔者最近变更到了RN的团队,回归到了hybrid app的开发的圈子中,固然是有蛮多新鲜感和新机遇的,不过遥想起以前在hybrid中各种view之前跳转的头疼等各种问题,笔者怀着忐忑的心 ...

  7. Service官方教程(3)Bound Services

    Bound Services 1.In this document The Basics Creating a Bound Service Extending the Binder class Usi ...

  8. github下载下来的C#控制台小游戏[含源码]

    早就听说了github是世界最大的源码库,但自己却不是很懂,今天去研究了下,注册了一个帐号,然后在上面搜索了一下C# game,然后发现有许多的游戏. 随意地选择了一个,感觉比较简单,于是就下载了下来 ...

  9. 工作记录 angular页面操作 MD5加密

    今天只是做页面,基于angularjs,有美工做的图打底,确实好用 密码保存,用到了C# MD5加密: https://www.cnblogs.com/healer007/p/5062189.html

  10. 初识react native遇到的问题

    Andriod 使用react native时遇到的问题     打开现有项目报错: 从第一行Error可以知道是一个zip的压缩文件打不开,往下看应该是下载的Gradle文件有问题,提示也是让从新下 ...