字符串的分割

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cstdio>
using namespace std;

int main()
{
    char str[105], s1[20], s2[20], num1[15], num2[15];
    memset(str, 0, 105);
    memset(s1, 0, 20);
    memset(s2, 0, 20);
    memset(num1, 0, 15);
    memset(num2, 0, 15);
    int i = 0, j = 0;
    fgets(str, 104, stdin);
    while (str[i] != '=') {
        s1[j++] = str[i++];
    }
    j = 0;
    while (str[i] != ',') {//从等号开始
        num1[j++] = str[i++];
    }
    j = 0;
    while (str[i] != '=') {//从逗号开始
        s2[j++] = str[i++];
    }
    j = 0;
    while (str[i] != '\0'&&str[i]!='\n') {//从等号开始
        num2[j++] = str[i++];
    }
    cout << s1 << num2 << s2 << num1 << endl;
    return 0;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 15:58
投个小米提前批试试水,先投一个岗位看看形势,不行就再沉淀一下投第二个岗位,莫辜负
Java抽象带篮子:我嘞个骚刚,已经开始研发6g了吗
投递小米集团等公司7个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务