新浪微博 2019校园招聘笔试编程题-2018.09.15

版权声明:本人ZZU在校学生,文章均为个人心得,有不足之处请不吝赐教! https://blog.csdn.net/whl_program/article/details/82719368

1-1.png

#include <iostream>
#include <cstring>
using namespace std;
char arr[255];
int main()
{
    string str1, str2;
    getline(cin, str1);
    getline(cin, str2);
    for(int i=0; i<str2.size(); i++){
        if(arr[str2[i]] == 0){
            arr[str2[i]] = 1;
        }
    }
    for(int i=0; i<str1.size(); i++){
        if(arr[str1[i]] == 0)
            cout << str1[i];
    }
    return 0;
}

2=1.png
2=2.png

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
void* str_copy(void* dst, const void* src, size_t size){
    if(src==NULL || size<=0)
        return dst;
    char* pdst = (char*)dst;
    const char* psrc = (const char *)src;
    if(pdst>psrc && pdst<psrc+size){//重合 从高地址往低地址拷贝
        pdst = pdst+size-1;
        psrc = psrc+size-1;
        while(size--)
            *pdst-- = *psrc--;
    }else{//从低地址往高地址拷贝
        while(size--)//从前往后拷贝
            *pdst++ = *psrc++;
    }
    return dst;
}
int main()
{
    char src[1000];
    char dst[1000];
    scanf("%s", &src);
    str_copy(dst, src, 1000);
    printf("%s", dst);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/whl_program/article/details/82719368