并不是很精简,随便改改A过了就没有再简化了。

1020.

Problem Description
Given a string containing only 'A' - 'Z', we could encode it using the following method:

1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only character in this sub-string.

2. If the length of the sub-string is 1, '1' should be ignored.

 
Input
The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only 'A' - 'Z' and the length is less than 10000.
 
Output
For each test case, output the encoded string in a line.
 
Sample Input
2
ABC
ABBCCC
 
Sample Output
ABC
A2B3C
 
 #include<iostream>
#include<string>
using namespace std;
int main()
{
int n,count;;
cin>>n;
while(n--)
{
string str;
cin>>str;
for(int i=;i<(int)str.length();i++)
{
count=;
while(str[i]==str[i+])
{
count++;i++;
}
if(count!=)
cout<<count;
cout<<str[i];
}
cout<<endl;
}
return ;
}

1020

1039.

Problem Description
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that are relatively secure but still easy to remember.

FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:

It must contain at least one vowel.

It cannot contain three consecutive vowels or three consecutive consonants.

It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.

(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.

 
Input
The input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.
 
Output
For each password, output whether or not it is acceptable, using the precise format shown in the example.
 
Sample Input
a
tv
ptoui
bontres
zoggax
wiinq
eep
houctuh
end
 
Sample Output
<a> is acceptable.
<tv> is not acceptable.
<ptoui> is not acceptable.
<bontres> is not acceptable.
<zoggax> is not acceptable.
<wiinq> is not acceptable.
<eep> is acceptable.
<houctuh> is acceptable.
 
 #include<iostream>
#include<string>
using namespace std;
bool search1(string str)
{
for(int i=;i<=(int)str.length()-;i++)
{
if(str[i]=='a'||str[i]=='e') return true;
if(str[i]=='i'||str[i]=='o'||str[i]=='u') return true;
}
return false;
}
bool search2(string str)
{
int count1=,count2=;
for(int i=;i<=(int)str.length()-;i++)
{
if(i!=&&str[i-]==str[i])
{if(str[i]=='o'||str[i]=='e');
else return false;}
if (str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
{
count1++;
count2=;
}
else
{
count2++;
count1=;
}
if(count1>=||count2>=)
return false;
}
return true;
}
int main()
{
string str;
while()
{
cin>>str;
if(str=="end")
break;
if(search1(str)&&search2(str))
cout<<'<'<<str<<'>'<<" is acceptable."<<endl;
else
cout<<'<'<<str<<'>'<<" is not acceptable."<<endl;
} }

1062.

Problem Description
Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
 
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
 
Output
For each test case, you should output the text which is processed.
 
Sample Input
3
olleh !dlrow
m'I morf .udh
I ekil .mca
 
Sample Output
hello world!
I'm from hdu.
I like acm.

Hint

Remember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it.

 
 #include<iostream>
#include<string>
using namespace std;
const int maxn=;
char a[maxn],b[maxn];
void print(char *str)
{
for(int i=strlen(str)-;i>=;i--)
cout<<str[i];
}
int main()
{
int n,i,j,len;
cin>>n;
getchar();
while(n--)
{
gets(a);
len=strlen(a);
a[len]=' ';
a[len+]='\0';
b[]='\0';
for(i=,j=;i<=len;i++)
{
if(a[i]==' ')
{
print(b);
b[]='\0';
cout<<(i==len?'\n':' ');
j=;
}
else
{
b[j]=a[i];
j++;
b[j]='\0';
}
}
}
return ;
}

1088.

Problem Description
If you ever tried to read a html document on a Macintosh, you know how hard it is if no Netscape is installed. 
Now, who can forget to install a HTML browser? This is very easy because most of the times you don't need one on a MAC because there is a Acrobate Reader which is native to MAC. But if you ever need one, what do you do? 
Your task is to write a small html-browser. It should only display the content of the input-file and knows only the html commands (tags) <br> which is a linebreak and <hr> which is a horizontal ruler. Then you should treat all tabulators, spaces and newlines as one space and display the resulting text with no more than 80 characters on a line.
 
Input
The input consists of a text you should display. This text consists of words and HTML tags separated by one or more spaces, tabulators or newlines. 
A word is a sequence of letters, numbers and punctuation. For example, "abc,123" is one word, but "abc, 123" are two words, namely "abc," and "123". A word is always shorter than 81 characters and does not contain any '<' or '>'. All HTML tags are either <br> or <hr>.
 
Output
You should display the the resulting text using this rules: 
  . If you read a word in the input and the resulting line does not get longer than 80 chars, print it, else print it on a new line. 
  . If you read a <br> in the input, start a new line. 
  . If you read a <hr> in the input, start a new line unless you already are at the beginning of a line, display 80 characters of '-' and start a new line (again). 
The last line is ended by a newline character.
 
Sample Input
Hallo, dies ist eine
ziemlich lange Zeile, die in Html
aber nicht umgebrochen wird.
<br>
Zwei <br> <br> produzieren zwei Newlines.
Es gibt auch noch das tag <hr> was einen Trenner darstellt.
Zwei <hr> <hr> produzieren zwei Horizontal Rulers.
Achtung mehrere Leerzeichen irritieren

Html genauso wenig wie

mehrere Leerzeilen.

 
Sample Output
Hallo, dies ist eine ziemlich lange Zeile, die in Html aber nicht umgebrochen
wird.
Zwei

produzieren zwei Newlines. Es gibt auch noch das tag
--------------------------------------------------------------------------------
was einen Trenner darstellt. Zwei
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
produzieren zwei Horizontal Rulers. Achtung mehrere Leerzeichen irritieren Html
genauso wenig wie mehrere Leerzeilen.

 
 #include<iostream>
char s[];
using namespace std;
int main()
{
int count=;
while(~scanf("%s",s))
{
if(!strcmp(s,"<br>"))
{
cout<<endl;
count=;
}
else if(!strcmp(s,"<hr>"))
{
if(count)
cout<<'\n';
cout<<"--------------------------------------------------------------------------------\n";
count=;
}
else
{
int length=strlen(s);
if(count==)
{
cout<<s;
count=length;
}
else if((count+length+)>=)
{
cout<<endl<<s;
count=length;
}
else
{
cout<<' '<<s;
count+=length+;
}
}
}
cout<<endl;
}

1161.

Problem Description
Eddy usually writes articles ,but he likes mixing the English letter uses, for example "computer science" is written frequently "coMpUtEr scIeNce" by him, this mistakes lets Eddy's English teacher be extremely discontentment.Now please you to write a procedure to be able in the Bob article English letter to turn completely the small letter. 
 
Input
The input contains several test cases.each line consists a test case,Expressed Eddy writes in an article , by letter, blank space,numeral as well as each kind of punctuation
composition, the writing length does not surpass 1000 characters.
 
Output
For each test case, you should output an only line, after namely the result of transforms the lowercase letter.
 
Sample Input
weLcOmE tO HDOj Acm 2005!
 
Sample Output
welcome to hdoj acm 2005!

 #include<iostream>
const int maxn=;
char str[];
using namespace std;
int main()
{
while(gets(str))
{
for(int i=;str[i]!='\0';i++)
{
if(str[i]>='A'&&str[i]<='Z')
str[i]+=;
}
cout<<str<<endl;
}
}

1200.

Problem Description
Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is “There’s no place like home on a snowy night” and there are five columns, Mo would write down

t o i o y
h p k n n
e l e a i
r a h s g
e c o n h
s e m o t
n l e w x

Note that Mo includes only letters and writes them all in lower case. In this example, Mo used the character ‘x’ to pad the message out to make a rectangle, although he could have used any letter.

Mo then sends the message to Larry by writing the letters in each row, alternating left-to-right and right-to-left. So, the above would be encrypted as

toioynnkpheleaigshareconhtomesnlewx

Your job is to recover for Larry the original message (along with any extra padding letters) from the encrypted one.

 
Input
There will be multiple input sets. Input for each set will consist of two lines. The first line will contain an integer in the range 2. . . 20 indicating the number of columns used. The next line is a string of up to 200 lower case letters. The last input set is followed by a line containing a single 0, indicating end of input.
 
Output
Each input set should generate one line of output, giving the original plaintext message, with no spaces.
 
Sample Input
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
 
Sample Output
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab
 #include<iostream>
using namespace std;
#include<string>
int main()
{
// freopen("F:\\in.txt","r",stdin);
//freopen("F:\\ou.txt","w",stdout);
string s;int c,t,count;
while(){
cin>>c;
if(!c) break;
cin>>s;
int n=int(s.length());
for(int k=;k<=c;k++)
{
t=k-;count=;
while(t<=n-)
{
cout<<s[t];
if(count%)
t+=*c--*(k-);
else
t+=*k-;
count++;
}
}
cout<<endl;
}
//fclose(stdin);
//fclose(stdout);
return ;
}

2017.

Problem Description
对于给定的一个字符串,统计其中数字字符出现的次数。
 
Input
输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
 
Output
对于每个测试实例,输出该串中数值的个数,每个输出占一行。
 
Sample Input
2
asdfasdf123123asdfasdf
asdf111111111asdfasdfasdf
 
Sample Output
6
9
 
 #include<iostream>
#include<cctype>
#include<string>
using namespace std;
int main()
{
int n,count;
cin>>n;
while(n--)
{
count=;
string str;
cin>>str;
for(string::iterator it=str.begin();it!=str.end();it++)
if(isdigit(*it))
count++;
cout<<count<<endl;
} }
 

HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)的更多相关文章

  1. hdu 5326(基础题) work

    http://acm.hdu.edu.cn/showproblem.php?pid=5326 一道水题,题目大意是在公司里,给出n个员工和目标人数m,然后下面的n-1行是表示员工a管理b,问在这些员工 ...

  2. HDU 1301 Jungle Roads (最小生成树,基础题,模版解释)——同 poj 1251 Jungle Roads

    双向边,基础题,最小生成树   题目 同题目     #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include<stri ...

  3. hdu 2089 不要62 (数位dp基础题)

    不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. Jam's balance HDU - 5616 (01背包基础题)

    Jim has a balance and N weights. (1≤N≤20) The balance can only tell whether things on different side ...

  5. 小试牛刀3之JavaScript基础题

    JavaScript基础题 1.让用户输入两个数字,然后输出相加的结果. *prompt() 方法用于显示可提示用户进行输入的对话框. 语法: prompt(text,defaultText) 说明: ...

  6. 小试牛刀2:JavaScript基础题

    JavaScript基础题 1.网页中有个字符串“我有一个梦想”,使用JavaScript获取该字符串的长度,同时输出字符串最后两个字. 答案: <!DOCTYPE html PUBLIC &q ...

  7. POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划)

    POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划) Descri ...

  8. Java面试题以及答案精选(架构师面试题)-基础题1

    基础题 一.String,StringBuffer, StringBuilder 的区别是什么?String为什么是不可变的?1. String是字符串常量,StringBuffer和StringBu ...

  9. C/C++笔试题(基础题)

    为了便于温故而知新,特于此整理 C/C++ 方面相关面试题.分享,共勉. (备注:各题的重要程度与先后顺序无关.不断更新中......欢迎补充) (1)分析下面程序的输出(* 与 -- 运算符优先级问 ...

随机推荐

  1. 在jupyter notebook中同时安装python2和python3

    之前讨论过在anaconda下安装多个python版本,本期来讨论下,jupyter notebook中怎样同时安装python2.7 和python3.x. 由于我之前使用的jupyter note ...

  2. crm管理系统

    开始的时候,我们小组开始先完成各自的静态页面,并实现页面的跳转. //部门主页面 //部门添加页面 //部门修改页面 并通过AJXA发送到后台,后台通过处理方法,并返回到前端. 需要注意的是:在下拉列 ...

  3. 无法将类型为excel.applicationclass的com 强制转换为接口类型的解决方法[转]

    c#解决方案EXCEL 导出 今天碰到客户的电脑在导出EXCEL的时候提示,无法将类型为 excel.applicationclass 的 com 强制转换为接口类型 excel._applicati ...

  4. 第二章:1.0 Django 入门和开发环境

    1. 选择 Django Web框架来做Web接口开发,主要原因是由于学习资料丰富,便于学习. 2. Django 对 python 版本的支持情况. Django 的版本在 1.8 ,1.9 , 1 ...

  5. Chrome浏览器扩展开发系列之四:Browser Action类型的Chrome浏览器扩展

    Browser Action类型的Google Chrome扩展程序,通常在Chrome浏览器的工具栏中,地址栏的右侧,有一个始终存在的图标.也就是说,这个图标与浏览器相关,只要安装了该Chrome扩 ...

  6. Android Studio和eclipse混淆打包总结

    最近项目有点闲,考虑到以前的项目没有做过混淆,只是用了加固软件进行加固,为了安全性,准备给项目加上,这里做个总结,都经本人亲自在项目实践,说是为了安全性,这好像说大了,一来项目中没用到什么特别的技术, ...

  7. (cljs/run-at (JSVM. :all) "Metadata就这样哦")

    前言  动态类型语言,少了静态类型语言必须声明变量类型的累赘,但也缺失了编译时类型检查和编译时优化的好处.cljs虽然作为动态类型语言,但其提供Metadata让我们在必要的时候可选择地补充类型提示, ...

  8. Android系统--输入系统(十六)APP跟输入系统建立联系_InputChannel和Connection

    Android系统--输入系统(十六)APP跟输入系统建立联系_InputChannel和Connection 0. 核心:socketpair机制 1. 回顾Dispatch处理过程: 1.1 放入 ...

  9. php工作两年了。。。

    对于一个快要毕业的人来说,我相信大部分人都是迷茫的,我也一样但是迷茫的一塌糊涂完全不知道以后自己能干什么. 2014年底,某某培训机构来到学校进行招生.反正在对方的一阵忽悠之下我是蠢蠢欲动,但是当时的 ...

  10. PHP树结构,实现无限分级

    一.从数据库查出来的数据需要id.parentid.level. id唯一识别栏目,parentid为该栏目所属父类id,level标示该栏目是几级栏目.以下代码就可以实现一个简单的树结构. publ ...