字符串的分割

#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;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
03-08 19:53
已编辑
AAA不喝拿铁:海投吧,感觉项目写的可以了,能cover住提问就行。我根据真实面经整理得到的最全(高/中/低频)面试题,适合面试前短期突击&长期提高补充,需要的牛u可以关注一手我的专栏,祝好运
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务