当前位置:网站首页>*1-2 OJ 190 run-length code
*1-2 OJ 190 run-length code
2022-08-09 14:49:00 【Leaf Xiao Bai】
题目描述

输入

输出

样例输入

样例输出

源代码
#include <stdio.h>
#include <string.h>
int main()
{
char str[105];
int i;
while(scanf("%s",str)!=EOF)
{
int k=0;
char a[105]={
'\0'};
int b[105]={
0};
for(i=0;i<strlen(str);i++)
{
if(i==0||str[i]==str[i-1])
{
b[k]++;
a[k]=str[i];
}
else
{
if(str[i]!=str[i+1])
{
k++;
a[k]=str[i];
}
else
{
k++;
}
}
}
for(i=0;i<=k;i++)
{
if(i==0)
{
printf("%d%c",b[i],a[i]);
}
else
{
printf("%d%c",b[i]+1,a[i]);
}
}
printf("\n");
}
return 0;
}
关于这题
str 输入
a 字符
b 个数
k 种类
注:This question does not consider the order 如果 ssaasd 输出结果为2s2a1s1d
边栏推荐
- 阿里云PAI与香港大学合作论文入选INFOCOM 2022,有效减少大规模神经网络训练时间
- 关于舵机的漂移与不听指挥乱动的问题
- [Video coding learning] - understanding of transformation
- 如何用vs新建Asp.net项目(Web页面)
- dpkg:错误:无法新建文件 ‘/var/lib/dpkg/info/format-new’: 没
- How to develop small programs?should focus on features
- Dry+Bean+Dataset R language data analysis, report in English
- CTF题解五 Web PHP大法(实验吧)
- 用asp.net基于C#编写简单登录注册界面(访问数据库)
- 11. cuBLAS Development Guide Chinese version--Level-1 functions amax() and amin() in cuBLAS
猜你喜欢
随机推荐
apt-cache 命令
汇编语言学习(二)
The use of Jetpack Compose - Button (Button)
word编号和文本间距过大
shell课程总结
C语言 一维数组和二维数组的定义及使用
display:inline-block 什么时候不会显示间隙?
使用Connection对象连接管理事务
微信小程序getPhoneNumber接口code=40013
Shell course summary
*1-1 OJ 56 Hamming Distance
#25-1 OJ 78 Calculate birthday day of the week
开源一夏│别逗,作为程序员你竟还没参与过开源项目?
Shell course summary
Badge of openharmony container components
Bubble sort (detailed)
Counter of openharmony container components
面试官:请说说什么是BFC?大白话讲清楚
RHCE课程总结
Kubernetes资源编排系列之三: Kustomize篇









