小九九的等待 发表于 2018-1-22 14:39:35

RE: S1E2:第一个程序 | 课后测试题及答案

进攻!

关山雪冷 发表于 2018-1-22 20:41:48

计算机无法直接读懂人类语言

机器语言

编译

编译型语言是通过编译转换成汇编语言再转换为机器语言,交由CPU执行,而解释型语言是转换为中介代码,再由解释器翻译成机器语言

可以

将源代码转化成中介代码再交由解释器翻译

查表

QIN MEN CHEN DI REN CHI FAN SHI FA DONG JIN GONG
亲们趁敌人吃饭时发动进攻

minki 发表于 2018-1-22 20:47:40

{:5_92:}

WQ海阔天空 发表于 2018-1-22 21:31:42

本帖最后由 WQ海阔天空 于 2018-1-22 21:33 编辑

目前,你总共写了0行代码。。。

我把源代码复制下来对比,不一样的地方都改了啊,怎么还是提示写了0行代码呢?

每行前面的空格多少不影响代码运行吧?

#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 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);
       
            _findclose(handle);
}

int main()
{
            char path = ".";
       
            printf("计算中...\n");
       
            findAllCodes(path);
            findALLDirs(path);
       
            printf("目前你总共写了 %ld 行代码!\n\n", total);
            system("pause");
       
            return 0;
}

明天重新写一下再试

lkaming 发表于 2018-1-23 10:59:04

QAQ

lovefishc.com 发表于 2018-1-23 11:36:53

0.计算机只认识0和1
1.机器语言
2.编译
3.编译型语言cpu能读懂,解释形语言需要解释器转换
4.能
5.解释器转换
6.01的排列
7. i love fishc.com

lovefishc.com 发表于 2018-1-23 11:37:47

0.计算机只认识0和1
1.机器语言
2.编译
3.编译型语言cpu能读懂,解释形语言需要解释器转换
4.能
5.解释器转换
6.01的排列
7. i love fishc.com

mjl 发表于 2018-1-23 12:41:07

查看答案

我爱摸鱼 发表于 2018-1-23 14:46:58

qin men cheng irenchieanshifadongjingoag

384615666 发表于 2018-1-23 19:01:45

1

John66 发表于 2018-1-24 11:16:39

zthh 发表于 2018-1-24 13:19:41

回复一下看答案

书的那页 发表于 2018-1-24 13:21:07

感谢楼主喽

a1296715528 发表于 2018-1-24 13:24:54

。。。

二七十四 发表于 2018-1-24 14:55:15

{:5_91:}

EastTao 发表于 2018-1-24 15:37:40

答案

BigVivian 发表于 2018-1-24 17:06:39

pianoer 发表于 2018-1-24 20:18:47

这帖子不错哦

aestival 发表于 2018-1-24 23:21:11

0. 只能读懂机器语言
1. 汇编
2. 编译
3. 需不需要解释器
4. 能
5. 解释器
6. 一一对应

Doraeeemon 发表于 2018-1-25 01:00:12

嘻嘻
页: 102 103 104 105 106 107 108 109 110 111 [112] 113 114 115 116 117 118 119 120 121
查看完整版本: S1E2:第一个程序 | 课后测试题及答案