zoukankan      html  css  js  c++  java
  • C提高_day03_作业第二题

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    /*==============================================================
    有一个字符串”1a2b3d4z”,;
            要求写一个函数实现如下功能,
    功能1:把偶数位字符挑选出来,组成一个字符串1。valude;20分
    功能2:把奇数位字符挑选出来,组成一个字符串2,valude 20
    功能3:把字符串1和字符串2,通过函数参数,传送给main,并打印。
    功能4:主函数能测试通过。
    int getStr1Str2(char *souce, char *buf1, char *buf2); 
    =================================================================*/
    void getStr1Str2(char *source,char *buf1,char *buf2)
    {
        int i=0;
        while(*source!='')
        {  
            if(i%2==0)
            {
                *buf1=*source;
                source++;
                buf1++;
                 ++i;
            }
            else
            {
                *buf2=*source;
                 source++;
                buf2++;
                ++i;
            }
        }
        *buf1='';
        *buf2='';
    }
    
    void main()
    {
    
        char *p ="1a2b3c4d5"; 
        char a[30];
        char b[30];
    
        getStr1Str2(p,a,b);
        printf("原字符串为  :%s
    ",p);
        printf("奇数字符串为:%s
    ",a);
        printf("偶数字符串为:%s
    ",b);
    
        system("pause");
    }
    Stay hungry,Stay foolish
  • 相关阅读:
    maven学习
    存储过程的作用
    数据库优化
    Springmvc整合mybatis
    Spring Mvc简介
    Axis2开发实例
    Mybatis之typeAlias配置的3种方法
    Spring AOP教程及实例
    spring AOP底层原理实现——jdk动态代理
    Java实现动态代理的两种方式
  • 原文地址:https://www.cnblogs.com/zhesun/p/4952485.html
Copyright © 2011-2022 走看看