接触C语言

#include"stdio.h"

#include"stdlib.h"

#include"string.h"



char* mystrcpy(char* lsh,char* rsh);



int main()

{

    char* p2 = "可以请你吃饭吗?";

    char* p1  = malloc(100);

    if(p1 == NULL)

      exit(1);

    mystrcpy(p1,p2);

    printf(p1);

    free(p1);

    return 0;

}



char* mystrcpy(char* lsh,char* rsh)

{

    int count;

    char* rs = lsh;

    char* rh = rsh;

    if(rs == rh)

       return rs;

    count = strlen(rsh) + 1;

    if(lsh>rsh || lsh<rsh + count)

    {

        while(count--)

        *lsh++ = *rsh++;

    }

    else

    {   rs = lsh + count;

        rh = rsh + count;

        while(count--)*rs-- = *rh --;

    }

    return lsh;

}

#include <stdio.h>



#include <stdlib.h>



#include <ctype.h>



#include <stdbool.h>



#define SIZE 100



int main(void)

{



    char a[SIZE];



    char ch;



    int i = 0;



    printf("Hello,Word!\n");



    while ((ch = getchar()) != '\n')

    {



    if (isalpha(ch))

    {



        a = tolower(ch);



        i++;



    }



    }



    a = '\0';            //这里千万要加上,不然会出错。



    puts(a);



    bool flag = true;



    int j;



    int k = i - 1;



    for (j = 0; k >= 0; k--, j++)

    {



    if (a[j] != a[k])

    {



        flag = false;



    }



    }



    if (flag)



    printf("Yes");



    else



    printf("NO");



    return 0;



}
#include <stdio.h>



#include <stdlib.h>



#define SIZE 100



int main(void)

{



    char Line[SIZE];



    char *p;



    int i = 0;



    while ((Line = getchar()) != '\n')



    i++;



    for (p = Line + i - 1; p >= Line; p--)



    printf("%c", *p);



    return 0;



}

 

你可能感兴趣的:(C语言)