弑魂气煞 发表于 2022-11-5 09:55:33

第一节课

弑魂气煞 发表于 2022-11-5 12:00:03

lkj

薄荷味回忆 发表于 2022-11-5 12:38:40

0.因为它只会按照固定的程序运行
1.机器语言
2.编译
3.不知道
4.不能
5.不知道
6.不知道
7.不知道

JZyxz 发表于 2022-11-5 14:38:55

0.
只懂得机器语言

1.
机器语言

2.
编译

3.
编译型语言,需要经过编译成汇编语言再转换成机器语言,cpu直接就能读懂
解释型语言,需要将全部代码逐句解释给cpu
因为编译型语言比解释型效率更高

4.
当然可以

5.
因为不需要编译,直接解释给cpu

6.
查表

7.
亲们,趁敌人吃饭,是发动进攻



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;
}

anjial 发表于 2022-11-5 14:58:30

daan

slliang 发表于 2022-11-5 15:55:00

做完了,查看参考答案

slliang 发表于 2022-11-5 15:59:42

为什么我编译结果是285行代码{:10_266:},复制那个文本代码上去,结果也是285,我不理解{:10_269:}

刘海云 发表于 2022-11-5 16:33:30

先写再看

allureking 发表于 2022-11-5 17:35:00

1

y-zero 发表于 2022-11-5 18:08:46

查看参考答案

1961218758 发表于 2022-11-5 20:10:08

1

muchly 发表于 2022-11-5 20:24:32

11

酱汁油麦 发表于 2022-11-5 20:39:36

{:10_277:}

酱汁油麦 发表于 2022-11-5 21:29:42

为什么我的运行结果是0行啊{:10_277:}file:///D:/%E9%85%B1%E6%B1%81%E6%B2%B9%E9%BA%A6/Screenshots/31.png

时十陵 发表于 2022-11-5 22:26:34

为什么我用vs2019打出来都是错误呢?"C:\Users\86132\Desktop\微信图片_20221104234117.jpg"

liujiuchao 发表于 2022-11-5 23:08:14

来啦

矢志矣 发表于 2022-11-5 23:22:49

{:5_109:}

小张困了 发表于 2022-11-6 00:18:20

0.他只能读懂0和1
1.机器语言
2.编译
3.编译型语言可以直接被CPU所执行
4.可以
5.通过解释器进行翻译
6.查表
7.

jujubudaju 发表于 2022-11-6 04:10:21

查看参考答案

王硕studying 发表于 2022-11-6 08:21:23

认真
页: 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 [1794] 1795 1796 1797 1798 1799 1800 1801 1802 1803
查看完整版本: S1E2:第一个程序 | 课后测试题及答案