C语言基础学习day10

1.终端输入一个数,递归输出它的每一位,例:123 输出:123,void为返回值。

#include<stdio.h>
#include<stdlib.h>
#include<string.h> 
void s(int n)
{
    if(n>9)
    s (n/10);
    printf("%d",n%10);
}

int main(int argc, const char *argv[])
{
    int num;
    scanf("%d", &num);
    s(num);
    putchar(10);

2.*p++和++*p的区别

*p++是先解引用p,再对p进行自增,++*p是先解引用p,再对p解引用的结果自增。

3.有以下定义,说明哪些量可以改变哪些不可以改变。

const char *p:p指向的内容不可更改,p可以更改。

const (char *) p:p指向的内容不可更改,p可以更改。

char * const  p:p指向的内容可更改,p不可以更改。

const char * const p:p指向的内容不可更改,p也不可更改。

char const *p:p指向的内容不可更改,p可以更改。

(char*)const p:p指向的内容可更改,p不可更改。

char const* const p:p指向的内容不可更改,p也不可更改。

4.终端输入字符串,使用指针完成删空格操作并逆置。

 #include<stdio.h>
#include<stdlib.h>
#include<string.h> 
void skg(char *p)
{
    int i = 0;
    int j = 0;
    while(*(p+i))
    {
        if(*(p+i)!=' ')
        {
            *(p+j)=*(p+i);
            j++;
        }
        i++;
    }
    *(p+j)=*(p+i);
}

void nizhi(char *p1)                      
{
    int len = strlen(p1);
    char tmp = *p1; 
    *p1 = *(p1 + len - 1);
    *(p1 + len - 1) = '\0';
    if(strlen(p1+1) > 1 )           
        nizhi(p1 + 1);
    *(p1 + len - 1) = tmp;             
}
int main(int argc, const char *argv[])

    char s[32];
    gets(s);
    skg(s);
    puts(s);
    nizhi(s);
    puts(s);

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值