uva122-Trees on the level
来源:互联网 发布:网络暴力 恐怖片 编辑:程序博客网 时间:2024/05/17 20:30
#include <iostream>#include <cstdio>#include <string>#include <map>#include <algorithm>using namespace std;const int N=260;string str[N];bool ffflag=true;struct Node{ string num; string dir;};bool cmp(Node a,Node b){ if(a.dir.length()==b.dir.length()){ if(a.dir==b.dir) ffflag=false; return a.dir<b.dir; } return a.dir.length()<b.dir.length();}int main(){ string str[N]; while(cin>>str[0]){ ffflag=true; Node point[N]; int counter=1; if(str[0]=="()"){ cout<<"not complete"<<endl; continue; } while(cin>>str[counter]){ if(str[counter]=="()") break; counter++; } int i,j,k; for(i=0;i<counter;i++){ for(j=1;j<str[i].length();j++){ if(str[i][j]==',') break; } point[i].num=str[i].substr(1,j-1); for(k=j;k<str[i].length();k++){ point[i].dir=str[i].substr(j+1,str[i].length()-j-2); if(point[i].dir.length()==0) point[i].dir=" "; } } sort(point,point+counter,cmp); bool flag=true,fflag=false; for(i=0;i<counter;i++){ if(point[i].dir.length()>1){ flag=false; string s=point[i].dir.substr(0,point[i].dir.length()-1); for(j=0;j<counter;j++){ if(point[j].dir==s){ flag=true; break; } } if(flag==false) break; } if(point[i].dir.length()==1){ if(point[i].dir==" "){ fflag=true; } } } if(!flag|| !fflag || !ffflag) cout<<"not complete"; else{ for(i=0;i<counter;i++){ cout<<point[i].num; if(i<counter-1){ cout<<" "; } } } cout<<endl; } return 0;}
0 0
- UVa122 Trees on the level
- uva122-Trees on the level
- uva122 trees on the level
- UVA122 - Trees on the level
- UVA122 Trees on the level
- UVa122:Trees on the level
- [UVA122]Trees on the level
- UVA122 trees on the level(BFS)
- UVA122 Trees on the level【二叉树】【BFS】
- uva122 Trees on the level(锻炼指针建一棵二叉树)
- Trees on the level(UVA122,二叉树的建立)
- Uva122 Trees on the level 二叉树的数组实现
- 例题6-7 UVa122 Trees on the level(树&&队列BFS&&sscanf字符串转整数)
- Uva122 Trees on the level【指针建立树+bfs遍历树】【例题6-7】
- UVA122 Trees on the level(二叉树建立与遍历)
- uva122 Trees on the level (数组,指针两种实现方式)
- TREES ON THE LEVEL
- Trees on the level
- 动画Animation
- 图片压缩
- USB传输类型
- js用户密码强度验证函数
- 约瑟夫C语言实现
- uva122-Trees on the level
- SQL常用命令使用方法:
- Java枚举用法
- 服务器硬盘主流RAID(RAID0、RAID1、RAID4、RAID5)的功能介绍
- TPM咨询公司简述看板管理的优点
- xml基础1
- The model used to open the store is incompatible with the one used to create the store
- wifi基本知识
- Servlet 表单数据