当前位置:网站首页>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 ;
边栏推荐
- std::shared_ ptr initialization: make_ shared&lt; Foo&gt; () vs shared_ ptr&lt; T&gt; (new Foo) [duplicate]
- Anta is actually a technology company? These operations fool netizens
- AI做题水平已超过CS博士?
- Scientific research cartoon | what else to do after connecting with the subjects?
- . Net applications consider x64 generation
- Digital recognition system based on OpenCV
- Unity脚本API—Time类
- Stress, anxiety or depression? Correct diagnosis and retreatment
- What is the future of the booming intelligent Internet of things (aiot) in recent years?
- Unity update process_ Principle of unity synergy
猜你喜欢
Interface fonctionnelle, référence de méthode, Widget de tri de liste implémenté par lambda
Case sharing | integrated construction of data operation and maintenance in the financial industry
Live broadcast preview | PostgreSQL kernel Interpretation Series II: PostgreSQL architecture
Talking about Net core how to use efcore to inject multiple instances of a context annotation type for connecting to the master-slave database
Blood cases caused by Lombok use
Big God explains open source buff gain strategy live broadcast
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"
函數式接口,方法引用,Lambda實現的List集合排序小工具
[North Asia data recovery] data recovery case of database data loss caused by HP DL380 server RAID disk failure
随机推荐
干货 | fMRI标准报告指南新鲜出炉啦,快来涨知识吧
C implementation defines a set of intermediate SQL statements that can be executed across libraries
Lombok使用引发的血案
What encryption algorithm is used for the master password of odoo database?
Audio and video technology development weekly | 252
MySQL - MySQL adds self incrementing IDs to existing data tables
Change the mouse pointer on ngclick - change the mouse pointer on ngclick
Implementation of web chat room
Laravel simply realizes Alibaba cloud storage + Baidu AI Cloud image review
TypeError: list indices must be integers or slices, not str
Redis sentinel mode realizes one master, two slave and three Sentinels
LNX efficient search engine, fastdeploy reasoning deployment toolbox, AI frontier paper | showmeai information daily # 07.04
The four most common errors when using pytorch
LeetCode 35. 搜索插入位置 —vector遍历(O(logn)和O(n)的写法---二分查找法)
Case sharing | integrated construction of data operation and maintenance in the financial industry
Unity script API - transform transform
MySQL~MySQL给已有的数据表添加自增ID
In today's highly integrated chips, most of them are CMOS devices
Essential basic knowledge of digital image processing
Solve the error of JSON module in PHP compilation and installation under CentOS 6.3