why5188 发表于 2020-8-21 19:38:04

本帖最后由 why5188 于 2020-8-21 19:40 编辑

这些是我做的测试题答案,两道题没答出来{:5_90:}

        /*第一课答题
        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
        亲们趁敌人吃饭时发动进攻
这个摩斯密码 我自己做了两遍,第一遍多打了一个字母,麻蛋

1762104056 发表于 2020-8-21 20:33:45

qinmenchendirenchifanshifadangjingong

甜仔 发表于 2020-8-21 22:06:19

所以故意埋了一个坑吗{:5_97:}

why5188 发表于 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, target;
       
        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;
       
        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 = ".";
       
        printf(计算中...\n);
       
        findALLCodes(path);
        findALLDirs(path);
       
        printf("目前你总共写了%ld 行代码! \n\n",total);
        system("pause");



        return 0;
}

heyanglearning 发表于 2020-8-21 22:58:58

谢谢您

why5188 发表于 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, target;
               
                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;
               
                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 ="l";
               
                printf("计算中。。。\n");
               
                findAllCodes(path);
                findALLDirs(path);
               
                printf("目前你总共写了 %ld 行代码! \n\n",total);
                system("pause");
               
                return 0;
}

XnzKi_ONA 发表于 2020-8-22 10:19:33

h'h'h'h

JY258 发表于 2020-8-22 10:26:12

1

寻琦 发表于 2020-8-22 10:56:21

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

人间失格【 发表于 2020-8-22 12:16:07

ooo

Ostudent 发表于 2020-8-22 13:09:56

对答案

情歌剑笙 发表于 2020-8-22 13:44:25

1

haifeng09 发表于 2020-8-22 14:41:50

1

dawn996 发表于 2020-8-22 14:59:12

查看参考答案

liangbbbp 发表于 2020-8-22 15:38:52

答案。。

DovahkiinX 发表于 2020-8-22 16:47:17

谢谢分享!

572345305 发表于 2020-8-22 16:54:31

.

1562303819 发表于 2020-8-22 17:16:49

666666666

15155499302 发表于 2020-8-22 18:09:50

初上手,相信自己能行

致郁系卷毛 发表于 2020-8-22 19:44:35

RE: S1E2:第一个程序 | 课后测试题及答案
页: 811 812 813 814 815 816 817 818 819 820 [821] 822 823 824 825 826 827 828 829 830
查看完整版本: S1E2:第一个程序 | 课后测试题及答案