并不是很精简,随便改改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. memcached使用文档

    使用memcached进行内存缓存 通常的网页缓存方式有动态缓存和静态缓存等几种,在ASP.NET中已经可以实现对页面局部进行缓 存,而使用memcached的缓存比ASP.NET的局部缓存更加灵活, ...

  2. Swift开发常用知识点

    #pragma mark - as/类型转换as? / as! 需要根据前面的返回值决定 有?证明可选,可能为空:需要弱解包 没有?证明一定有值:大胆解包 as? 前面的结果是可选的 if let / ...

  3. visual studio for mac在线安装网络错误

    vs2017 for mac 终于出正式版了,兴冲冲的准备摆脱虚拟机. 官网https://www.visualstudio.com/zh-hans/vs/visual-studio-mac/下了安装 ...

  4. 《javascript高级程序设计》笔记七

    第五章 引用类型(三) 今天首先说的就是Function类型.下面就是定义函数的两种方法,第一种使用函数声明语法定义,第二种使用函数表达式定义.这两种定义函数的方式几乎没有什么区别. function ...

  5. MinGW(GCC)编译DLL文件

    这两天用CB(Code::Blocks)写个小程序,要编译出DLL供VB(6)使用.CB使用mingw-gcc作为编译器,在库文件的产出上跟VC.VS之类的IDE略有不同. 由于C语言的基础知识不是太 ...

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

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

  7. SQL Server分页查询方法整理

    SQL Server数据库分页查询一直是SQL Server的短板,闲来无事,想出几种方法,假设有表ARTICLE,字段ID.YEAR...(其他省略),数据53210条(客户真实数据,量不大),分页 ...

  8. 64位Win10系统安装Mysql5.7.11

    最近在装了64位Win10系统的mac book笔记本上用mysql-installer-community-5.7.11.0安装Mysql5.7.11,在配置mysql server时老是卡住,报错 ...

  9. 使用ajax提交form表单(转)

    前言 使用ajax请求数据,很多人都会,比如说: $.post(path,{data:data},function(data){ ... },"json"); 又或者是这样的aja ...

  10. Microsoft office2010页码设置----论文、课程设计报告格式

    思想:将目录页(含目录页)与目录页以下的页面用分隔符分隔开,单独设置目录页以下的页面页码,删除目录页(含目录)以前的页码. 1.在目录页页面内容最下面一行插入分隔符,实现与下面页面分隔开的目的. 页面 ...