《啊哈,C语言》 第一章课后习题练习记录


我本硕都是文学专业的学生,称得上是一只超级超级菜鸟,今天偶然在公众号上《啊哈,C语言》这本书的介绍,感觉很适合我入门C语言。于是我决定对我的练习过程做一下记录,希望再次回顾时,我能从一只超级超级菜鸟进化成一只超级菜鸟~~

第三节 P27

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述

#include <stdio.h>
#include <stdlib.h>
int main()
{
    system("color 27");
    printf("hi");
    sleep("5000");
    return 0;
}

第一题

在这里插入图片描述

我的解答:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    system("color f4");
    printf("      *\n");
    printf("      **\n");
    printf("*     ***\n");
    printf("**    ****\n");
    printf("**************\n");
    printf("**    ****\n");
    printf("*     ***\n");
    printf("      **\n");
    printf("      *\n");
    return 0;
}

第二题

在这里插入图片描述

我的解答:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    system("color f2");
    printf("A\n");
    printf("I*\n");
    printf("I**\n");
    printf("I***\n");
    printf("I****\n");
    printf("I*****\n");
    printf("I\n");
    printf("I\n");
    printf("I\n");
    printf("I\n");
    
    return 0;
}

第四节 P35

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述

第一题

在这里插入图片描述

我的解答:

###第一个算式:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    a=123456789;
    b=43214321;
    c=a+b;
    printf("%d",c);
    return 0;
}

###第二个算式:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    a=7078;
    b=8712;
    c=a*b;
    printf("%d",c);
    return 0;
}

###第三个算式:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c,d,e;
    a=123456;
    b=54321;
    c=321;
    d=a+b;
    e=c*d;
    printf("%d",e);
    return 0;
}

第五节 P45

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述

第二题

在这里插入图片描述

我的解答:

### 第一个算式:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    float a,b,c,d,e;
    a=1.2;
    b=2.3;
    c=3.4;
    d=4.5;
    e=a+b+c+d;
    printf("%f",e);
    return 0;
}

### 第二个算式:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    float a,b,c,d,e;
    a=1.1;
    b=100;
    c=a*b;
    printf("%f",c);
    return 0;
}

### 第三个算式:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    float a,b,c;
    a=10;
    b=10.1;
    c=b*(a*a);
    printf("%f",c);
    return 0;
}
或者:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    float a,b,c,d,e;
    a=10;
    b=10.1;
    c=a*a;
    d=b*c;
    printf("%f",d);
    return 0;
}

第六节 P50

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述

第一题

在这里插入图片描述

我的解答:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c,d,e,f;
    a=9;
    b=3;
    c=a+b;
    d=a-b;
    e=a*b;
    f=a/b;
    printf("%d+%d=%d\n",a,b,c);
    printf("%d-%d=%d\n",a,b,d);
    printf("%d*%d=%d\n",a,b,e);
    printf("%d/%d=%d",a,b,f);
    return 0;
}

### 或者:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c,d,e,f;
    a=9;
    b=3;
    c=a+b;
    printf("%d+%d=%d\n",a,b,c);
    c=a-b;
    printf("%d-%d=%d\n",a,b,c);
    c=a*b;
    printf("%d*%d=%d\n",a,b,c);
    c=a/b;
    printf("%d/%d=%d\n",a,b,c);
    return 0;
}

第七节

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述

第一题

在这里插入图片描述

我的解答:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    c=a+b;
    printf("%d+%d=%d\n",a,b,c);
    c=a-b;
    printf("%d-%d=%d\n",a,b,c);
    c=a*b;
    printf("%d*%d=%d\n",a,b,c);
    c=a/b;
    printf("%d/%d=%d",c);
    
    return 0;
}

第八节

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述

第十节 P72

一起来找茬

在这里插入图片描述

我的解答:

在这里插入图片描述


版权声明:本文为qq_52652441原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。