uva124
来源:互联网 发布:sketchup看图软件 编辑:程序博客网 时间:2024/06/04 20:00
#include <iostream>#include <stdio.h>#include <algorithm>#include <string.h>using namespace std;char v[21];char c[500];bool map_[26][26];int main(){ //freopen("debug\\in.txt","r",stdin); //freopen("debug\\out.txt","w",stdout); int t=0; while(gets(v))//gets()读取带空格的字符串 { if(t) printf("\n"); memset(map_,0,sizeof(map_)); remove(v,&v[sizeof(v)],' '); int len=strlen(v); sort(v,v+len);//为了方便后面的全排列 gets(c); remove(c,&c[sizeof(c)],' '); int len1=strlen(c); for(int i=0; i<len1; i+=2) map_[c[i]-'a'][c[i+1]-'a']=1; do { bool flag=true; for(int i=0; i<len; i++) for(int j=i+1; j<len; j++) if(map_[v[j]-'a'][v[i]-'a']) flag=false; if(flag) printf("%s\n",v); } while(next_permutation(v,&v[len]));//这个next_permutation()可以重新排列定义的范围内的字符串 t++; } return 0;}
#include <iostream>#include <algorithm>#include <string.h>using namespace std;int main(){ string s="1122234225"; remove(s.begin(),s.end(),'2'); cout<<s; return 0;}//输出:1134534225,把后面不是2的向前移动,后面的5个和原来保持一样,没有变化,//如果想把后面的也删除掉,就用erase();
#include <iostream>#include <algorithm>#include <string.h>using namespace std;int main(){ string s="1122234225"; s.erase(remove(s.begin(),s.end(),'2'),s.end()); cout<<s; return 0;}输出:11345
阅读全文
0 0
- uva124
- UVa124 - Following Orders
- 修改注册表解决 Win7 DbgView 不显示调试信息
- Notepad++快捷键
- XList的集成使用+AsyncTask
- 阿里云搭建SS代理超详细教程!!!
- Ryu控制器代码解析-任意地址Ping应答
- uva124
- Android 端天气预报APP的实现(五)全国各地城市数据的获取
- Swift网络请求(Moya篇)
- [Leetcode] 443. String Compression 解题报告
- android sdk 与java jdk之间的对应关系
- 自适应布局小结
- classpath、path、JAVA_HOME的作用及JAVA环境变量配置
- 详解浏览器最大并发连接数
- Insufficient space for shared memory file 磁盘空间不足