栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3056 As A Wlohe

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3056 As A Wlohe

#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#include <map>using namespace std;char c ,s[30];string haves[20000],temp;map<string,int>mp;int mtop=0;int hash( string s ){if ( mp[s] != 0 )return mp[s];mp[s] = ++ mtop;return mtop;} int main(){int top = 0 ;while ( scanf("%s" , s ) == 1 ){if ( s[0] == 'D' )break;int l = strlen(s) - 1 ;top ++ ;temp.clear();for ( int i = 0 ; i <= l ; i ++)haves[top] += s[i] ; if ( l > 1 )stable_sort(s+1,s+l);for ( int i = 0 ; i <= l ; i ++)temp += s[i] ;  hash(temp); memset(s,0,sizeof(s));}getchar();int now = 0 ,l=0;int first,last;temp.clear();while ( scanf("%c" , &c) == 1 ){if ( c >= 'a' && c <= 'z' ){temp += c;}else{if ( temp != "" ){memset(s,0,sizeof(s));int l = temp.size();for ( int i = 0 ; i < l; i ++)s[i] = temp[i];if ( l > 2 )stable_sort(s+1,s+ l -1);temp.clear();for ( int i = 0 ; i< l ; i ++)temp += s[i] ;cout<<haves[hash(temp)];}temp.clear();printf("%c",c);}}if ( temp != "" ){memset(s,0,sizeof(s));int l = temp.size();for ( int i = 0 ; i < l; i ++)s[i] = temp[i];if ( l > 2 )stable_sort(s+1,s+ l -1);temp.clear();for ( int i = 0 ; i< l ; i ++)temp += s[i] ;cout<<haves[hash(temp)];}}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/372188.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号