当前位置:网站首页>MFC implementation of ACM basic questions encoded by the number of characters
MFC implementation of ACM basic questions encoded by the number of characters
2022-07-04 16:18:00 【bcbobo21cn】
The English description of the problem is as follows ;
Problem Description
Given a stringcontaining 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 linecontains an integer N (1 <= N <= 100) which indicates the number of testcases. The next N lines contain N strings. Each string consists of only 'A' -'Z' and the length is less than 10000.
Output
For each testcase, output the encoded string in a line.
for example , Enter the following two lines ,
ABC
ABBCCC
The output of
ABC
A2B3C
Console C++ The program and output are as follows ;
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
// const int MAXN=10005;
char a[10005];
int main()
{
int i,temp;
int T;
scanf("%d",&T);// Two sets of test data
while(T--)
{
scanf("%s",&a);// The input is a string
i=0;
while(a[i]!='\0')// This is the sign to judge the end of the string
{
temp=i;
while(a[temp+1]==a[i])
{
temp++;
}
if(temp>i)
printf("%d",temp-i+1);
printf("%c",a[i]);
i=temp;
i++;
}
printf("\n");
}
return 0;
}
VC++2012 Create a new dialog project ;
void CcencDlg::OnBnClickedButton1()
{
// TODO: Add control notification handler code here
//char a[100];
CString strc, stre;
int i,temp;
CString str1;
GetDlgItem(IDC_EDIT1)->GetWindowTextW(strc);
i=0;
while(i<strc.GetLength())
{
temp=i;
while(strc.GetAt(temp+1)==strc.GetAt(i))
{
temp++;
}
if(temp>i)
{
//printf("%d",temp-i+1);
str1.Format(_T("%d"),temp-i+1);
stre.Append(str1);
}
//printf("%c",a[i]);
stre.Append((CString)strc.GetAt(i));
i=temp;
i++;
}
SetDlgItemText(IDC_EDIT2,stre);
}Operation of the ;

边栏推荐
- The 17 year growth route of Zhang Liang, an open source person, can only be adhered to if he loves it
- A trap used by combinelatest and a debouncetime based solution
- Hidden communication tunnel technology: intranet penetration tool NPS
- Data Lake Governance: advantages, challenges and entry
- 函數式接口,方法引用,Lambda實現的List集合排序小工具
- Preliminary practice of niuke.com (10)
- .Net 应用考虑x64生成
- Understand the context in go language in an article
- What should ABAP do when it calls a third-party API and encounters garbled code?
- Solve the error of JSON module in PHP compilation and installation under CentOS 6.3
猜你喜欢

Working group and domain analysis of Intranet

Move, say goodbye to the past again

Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"

干货 | fMRI标准报告指南新鲜出炉啦,快来涨知识吧

Quelles sont les perspectives de l'Internet intelligent des objets (aiot) qui a explosé ces dernières années?

2022年九大CIO趨勢和優先事項

What should ABAP do when it calls a third-party API and encounters garbled code?
![[hcie TAC] question 5 - 1](/img/e0/1b546de7628695ebed422ae57942e4.jpg)
[hcie TAC] question 5 - 1

Dry goods | fMRI standard reporting guidelines are fresh, come and increase your knowledge
Redis sentinel mode realizes one master, two slave and three Sentinels
随机推荐
Essential basic knowledge of digital image processing
Anta is actually a technology company? These operations fool netizens
Intranet penetrating FRP: hidden communication tunnel technology
干货 | fMRI标准报告指南新鲜出炉啦,快来涨知识吧
Case sharing | integrated construction of data operation and maintenance in the financial industry
Unity script lifecycle day02
Unity脚本介绍 Day01
Talking about Net core how to use efcore to inject multiple instances of a context annotation type for connecting to the master-slave database
Overview of convolutional neural network structure optimization
Dry goods | fMRI standard reporting guidelines are fresh, come and increase your knowledge
What is the future of the booming intelligent Internet of things (aiot) in recent years?
函数式接口,方法引用,Lambda实现的List集合排序小工具
std::shared_ ptr initialization: make_ shared&lt; Foo&gt; () vs shared_ ptr&lt; T&gt; (new Foo) [duplicate]
Selenium browser (2)
Solve the error of JSON module in PHP compilation and installation under CentOS 6.3
C language: implementation of daffodil number function
Book of night sky 53 "stone soup" of Apache open source community
The new generation of domestic ORM framework sagacity sqltoy-5.1.25 release
MySQL学习笔记——数据类型(数值类型)
The content of the source code crawled by the crawler is inconsistent with that in the developer mode