当前位置:网站首页>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 ;
边栏推荐
- lnx 高效搜索引擎、FastDeploy 推理部署工具箱、AI前沿论文 | ShowMeAI资讯日报 #07.04
- MySQL learning notes - data type (2)
- LeetCode 1184. Distance between bus stops -- vector clockwise and counterclockwise
- MySQL federated primary key_ MySQL creates a federated primary key [easy to understand]
- std::shared_ ptr initialization: make_ shared&lt; Foo&gt; () vs shared_ ptr&lt; T&gt; (new Foo) [duplicate]
- Redis shares four cache modes
- [Previous line repeated 995 more times]RecursionError: maximum recursion depth exceeded
- Unity脚本API—Transform 变换
- [tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection
- Find numbers
猜你喜欢
Common API day03 of unity script
The 17 year growth route of Zhang Liang, an open source person, can only be adhered to if he loves it
Using celery in projects
MySQL学习笔记——数据类型(数值类型)
What is torch NN?
Ten clothing stores have nine losses. A little change will make you buy every day
Case sharing | integrated construction of data operation and maintenance in the financial industry
MySQL学习笔记——数据类型(2)
MYSQL索引优化
Overview of convolutional neural network structure optimization
随机推荐
Case sharing | integrated construction of data operation and maintenance in the financial industry
MySQL index optimization
Blood cases caused by Lombok use
C implementation defines a set of intermediate SQL statements that can be executed across libraries
Nine CIO trends and priorities in 2022
How can floating point numbers be compared with 0?
AI做题水平已超过CS博士?
. Net applications consider x64 generation
@EnableAspectAutoJAutoProxy_ Exposeproxy property
MySQL~MySQL给已有的数据表添加自增ID
【读书会第十三期】 音频文件的封装格式和编码格式
Unity script lifecycle day02
MySQL学习笔记——数据类型(数值类型)
Big God explains open source buff gain strategy live broadcast
Ten clothing stores have nine losses. A little change will make you buy every day
Functional interface, method reference, list collection sorting gadget implemented by lambda
What is torch NN?
Interface test - knowledge points and common interview questions
PXE network
JS to realize the countdown function