热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ACM省选赛1001J2JEncryption

JohnandJackaregoodfriends,andbothofthemlikeadventures,buttheirparentsdonotwan
John and Jack are good friends, and both of them like adventures, but their parents do not want them to make troubles here and there, after their making numerous times of troubles, their parents had to forbid the frequency of their meetings. They could only tell each other the time and place of next adventure through letters.
Of course, sometimes, they just write graffiti, to confuse their parents who were in deep curiosity.

To stop their parents from being aware of the contents of their letters, clever John and Jack invented an encryption rule that belongs only to them: J2J Encryption.

The J2J Encryption was as follows:

Only three types of characters--uppercase, lowercase letters and numbers could appear in their character string, and the number of characters in the string should be less than 100.

If one had to put I at the ith position of the string, then put it at the nearest position that was after I and had the same character with it. The last one of each type should be put at the first position of the same type of the character string. If there was only one character in a tyre, no change would be needed.

For example: If there were only three lowercase letters a,b and c in the character string, and they were at the second, forth and sixth position, when encrypted, a was at the forth position, b at the sixth, and c at the second.

Uppercase letters and numbers were under the same encryption rule.

John had written the letter to Jack, now please encrypt it.

Input
First line is an integer n indicate there are n test cases, then n line strings followed.

Output
Output the encrypted string.

Sample input

3
a1W
abc
12a2bRcX

Sample output

a1W
cab
21c2aXbR
郁闷就差一题晋级^^^^^
回来还是写了一下
#include "iostream"
#include
#include "string"
using namespace std;
char*cstr=NULL;
char*cstrNum=NULL;
char*cstrLow=NULL;
char*cstrUpp=NULL;
void Move(string s,char *ctemp)
{
 
 cstr=ctemp;
 strcpy(cstr,s.c_str());
 char ch=cstr[s.length()];
 for (int i=s.length()-1;i>=0;i--)
 {
  cstr[i+1]=cstr[i];
 }
 cstr[0]=cstr[s.length()];
 cstr[s.length()]='/0';
 
}

void main()
{
 int n,i;
 cin>>n;
 for (i=0;i {
  string str,strNum,strLow,strUpp;
  char*c = new char[str.length() + 1];
  cin>>str;
  // c=*(str.c_str());
  strcpy(c,str.c_str());
  for (int j=0;j  {
   if (isdigit(c[j]))
   {
    strNum+=c[j];
    
   }
   if (islower(c[j]))
   {
    strLow+=c[j];
    
   }
   if (isupper(c[j]))
   {
    strUpp+=c[j];
   
   }
   
  }
  int coutNum=0,coutLow=0,coutUpp=0;
  cstrNum = new char[str.length() + 1];
  
  cstrLow = new char[str.length() + 1];
  cstrUpp = new char[str.length() + 1];
  Move(strNum,cstrNum);
  Move(strLow,cstrLow);
  Move(strUpp,cstrUpp);
  for (j=0;j  {
   if (isdigit(c[j]))
   {
    cout<    coutNum++;
   }
   if (islower(c[j]))
   {
    cout<    coutLow++;
    
   }
   if (isupper(c[j]))
   {
     cout<    coutUpp++;
    
   }
   
  }
  cout< }
 delete[]cstrNum;
 delete[]cstrLow;
 delete[]cstrUpp;
}

推荐阅读
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 本文讨论了使用差分约束系统求解House Man跳跃问题的思路与方法。给定一组不同高度,要求从最低点跳跃到最高点,每次跳跃的距离不超过D,并且不能改变给定的顺序。通过建立差分约束系统,将问题转化为图的建立和查询距离的问题。文章详细介绍了建立约束条件的方法,并使用SPFA算法判环并输出结果。同时还讨论了建边方向和跳跃顺序的关系。 ... [详细]
  • 本文介绍了如何在给定的有序字符序列中插入新字符,并保持序列的有序性。通过示例代码演示了插入过程,以及插入后的字符序列。 ... [详细]
  • 本文介绍了一种划分和计数油田地块的方法。根据给定的条件,通过遍历和DFS算法,将符合条件的地块标记为不符合条件的地块,并进行计数。同时,还介绍了如何判断点是否在给定范围内的方法。 ... [详细]
  • 本文介绍了解决二叉树层序创建问题的方法。通过使用队列结构体和二叉树结构体,实现了入队和出队操作,并提供了判断队列是否为空的函数。详细介绍了解决该问题的步骤和流程。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 本文介绍了游标的使用方法,并以一个水果供应商数据库为例进行了说明。首先创建了一个名为fruits的表,包含了水果的id、供应商id、名称和价格等字段。然后使用游标查询了水果的名称和价格,并将结果输出。最后对游标进行了关闭操作。通过本文可以了解到游标在数据库操作中的应用。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
author-avatar
mobiledu2502862707
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有