鱼C论坛

 找回密码
 立即注册
楼主: 小甲鱼

[课后作业] S1E2:第一个程序 | 课后测试题及答案

    [复制链接]
发表于 2020-8-21 13:55:07 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-21 14:13:59 | 显示全部楼层
二进制
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 15:40:08 | 显示全部楼层
查看参考答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 15:45:35 | 显示全部楼层
我抄的一模一样但是为啥运行还是老实不通过哭了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 16:30:59 | 显示全部楼层
windows代码无法运行。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 16:37:05 | 显示全部楼层
xiaoyunb
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 17:45:41 | 显示全部楼层
1488
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-21 17:52:36 | 显示全部楼层
加油欧力给
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 19:38:04 | 显示全部楼层
本帖最后由 why5188 于 2020-8-21 19:40 编辑

这些是我做的测试题答案,两道题没答出来

        /*第一课答题
        0. 不懂人类语言,不会像人类一样思考。
        1.计算机只会机器语言0和1
        2. 编译
        3.
        4.可以
        5.
        6.摩斯密码的原理是查字母表对比
        7.QINMENCHENDIRENCHIFANSHIFANDONGJINGONG
        7.1 qinmen亲们  
        7.2 chend
        7.3 irenc
        7.4 hifan
        7.5 shif
        7.6 adong
        7.7 jingo
        7.8 ng
        亲们趁敌人吃饭时发动进攻
这个摩斯密码 我自己做了两遍,第一遍多打了一个字母,麻蛋
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 20:33:45 | 显示全部楼层
qinmenchendirenchifanshifadangjingong
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 22:06:19 | 显示全部楼层
所以故意埋了一个坑吗
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 22:14:16 | 显示全部楼层
我的动动手作业 ,错误提示在附件里,错误提示有点多,没有全部截图。。。
#include <stdio.h>

main ()
#include <io.h>
#include <direct.h>
#include <stdlib.h>
#include <string.h>
#define MAX 256
long total;

int countlines(const char *filename);
void findAllCodes(const char *path);
void findAlLLFiles(const char *path);

int countLines(const char *filename)

{
        FILE *fp;
        int count = 0;
        int temp;
       
        if ((fp = fopen(filename, "r"))==NULL)
        {
                fprintf(stderr,"Can not open the file:%s\n",filename);
                return 0;
        }
        while ((temp = fgetc(fp)) !=EOF)
        {
                if (temp == '\n')
                {
                        count++;
                }
        }
        fclose(fp);
       
        return count;
}

void findAllCodes(const char *path)
{
        struct _finddata_t fa;
        long handle;
        char thepath[MAX], target[MAX];
       
        strcpy(thepath,path);
        if((handle = _findfirst(strcat(thepath,"/*.c"),&fa)) != -1L)
        {
                do
                {
                        sprintf(target,"%s/%s",path,fa.name);
                        total += countlines(target);
                }while (_findnext(handle,&fa)==0);
        }
        _findclose(handle);
}
void findALLDirs(const char *path)
{
        struct _finddata_t fa;
        long handle;
        char thepath[MAX];
       
        strcpy(thepath,path);
        if((handle = _findfirst(strcat(thepath,"/*"),&fa))== -1L)
        {
                fprintf(stderr,"The path %s is wrong!\n",path);
                return;
        }
        do
        {
                if (!strcmp(fa.name,".") || !strcmp(fa.name, ".."))
                        continue;
                       
                        if(fa.attrib == _A_SUBDIR)
                        {
                                        sprintf(thePath,"%s/%s",path, fa,name);
                                        findAllCodes(thePath);
                                        findALLDirs(thePath);
                        }
        }while (_findnext(handle,&fa) ==0);
       
        _findclost(handle);
}
int main()
{
        char path[MAX] = ".";
       
        printf(计算中...\n);
       
        findALLCodes(path);
        findALLDirs(path);
       
        printf("目前你总共写了%ld 行代码! \n\n",total);
        system("pause");



        return 0;
}
QQ图片20200821221303.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 22:58:58 | 显示全部楼层
谢谢您
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-21 23:37:16 | 显示全部楼层
本帖最后由 why5188 于 2020-8-21 23:38 编辑

@小甲鱼 老大批一下作业,
第二次手打作业了,比第一次少了好多错误,但是最后剩下的这个错误没解决掉,帮我看一下。
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX     256

long total;

int countLines(const char *filename);
void findAllCodes(const char *path);
void findALLFiles(const char *path);

int contLines(const char *filename)
{
        FILE *fp;
        int count = 0;
        int temp;
       
        if ((fp = fopen(filename,"r")) == NULL)
        {
                        fprintf(stderr, "Can not open the file:%s\n",filename);
                        return 0;
        }
        while ((temp = fgetc(fp)) != EOF)
        {
                if (temp =='\n')
                {
                        count++;
                }
        }
        fclose(fp);
       
        return count;
}

void findAllCodes(const char *path)
{
                struct _finddata_t fa;
                long handle;
                char thePath[MAX], target[MAX];
               
                strcpy(thePath, path);
                if((handle = _findfirst(strcat(thePath, "/*.c"), &fa)) != -1L)
                {
                                do
                                {
                                                sprintf(target, "%s/%s", path, fa.name);
                                                total += countLines(target);
                                }while (_findnext(handle, &fa) == 0);
                }
               
                _findclose(handle);
}

void findALLDirs(const char *path)
{
                struct _finddata_t fa;
                long handle;
                char thePath[MAX];
               
                strcpy(thePath, path);
                if((handle = _findfirst(strcat(thePath, "/*"),&fa)) == -1L)
                {
                                fprintf(stderr,"The path %s is wrong!\n",path);
                                return;
                }
               
                do
                {
                                if (!strcmp(fa.name, ".") || !strcmp(fa.name, ".."))
                                                continue;
                                               
                                                if( fa.attrib == _A_SUBDIR)
                                                {
                                                                sprintf(thePath, "%s/%s", path, fa.name);
                                                                findAllCodes(thePath);
                                                                findALLDirs(thePath);
                                                }
                }while (_findnext(handle, &fa) == 0);
               
                _findclose(handle);
}
int main()
{
                char path[MAX] ="l";
               
                printf("计算中。。。\n");
               
                findAllCodes(path);
                findALLDirs(path);
               
                printf("目前你总共写了 %ld 行代码! \n\n",total);
                system("pause");
               
                return 0;
}
222222222.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-22 10:19:33 | 显示全部楼层
h'h'h'h
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-22 10:26:12 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-22 10:56:21 | 显示全部楼层
0.负责执行命令的CPU只能认识二进制的0和1,不能直接理解汇编语言及其他的高级语言。
1.只包含0和1的机器语言。
2.编译
3.编译型语言在程序执行之前,有一个单独的编译过程,将程序翻译成机器语言就不用再进行翻译了。
解释型语言,是在运行的时候将程序翻译成机器语言。
4.不能直接在Windows系统上执行,需要稍加改变。
5.编译型语言虽然是高级语言,却与平台联系比较紧密(操作系统都是用编译型语言编写的),因此针对不同平台(操作系统)可能有其特定的编写规则,放到其他平台上面,自然编译执行不了。而解释型语言先天就和平台联系很少,所以,用解释型语言写出来的一份同样的程序,只要通过不同的解释器解释,就可以在对应不同的平台上使用。
6.最早的摩斯密码是一些表示数字的点和划。数字对应单词,需要查找一本代码表才能知道每个词对应的数。用一个电键可以敲击出点、划以及中间的停顿。
7.亲们趁敌人吃饭时发动进攻
C:\Users\WQ\Desktop\插入图片\2.1.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-22 12:16:07 | 显示全部楼层
ooo
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-22 13:09:56 | 显示全部楼层
对答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-22 13:44:25 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-15 07:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表