admin管理员组

文章数量:1794759

字符串处理

分类:字符串处理

关键字:字符串、空格、末尾‘,’输出处理

截图如下

题目要求

代码如下

代码语言:javascript代码运行次数:0运行复制
#include<iostream>
#include<stdio.h>
#include<string.h>

using std::cout;
//using namespace std;           //以上三行可以用using namespace std;代替

int main()
{
    char s[1001];
    gets(s);
    int i = strlen(s);
    int q = i;
    int c = 0;
    for( ; i>0; i--)
    {
        if(s[q - i] == ' ')
        {
            cout<<c<<',';
            c = 0;
        }
        else if(i == 1)
        {
            cout<<++c;
            break;
        }
        else
            c++;
    }
    return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2024-12-19,如有侵权请联系 cloudcommunity@tencent 删除using统计字符串coutint

本文标签: 字符串处理