Hisatri 发表于 2026-1-31 17:26:24

111

蓝色龙虾 发表于 2026-1-31 20:58:32


#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 findALLDirs(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;
}

缪志阳 发表于 2026-1-31 21:08:00

好的

dream_0917 发表于 2026-1-31 22:13:51

向小楼 发表于 2026-2-1 00:57:00

109

818877979 发表于 2026-2-1 08:50:06

看看

小pu 发表于 2026-2-1 13:28:03

1

街边 发表于 2026-2-1 14:32:35

1

不吃酸菜鱼 发表于 2026-2-2 00:54:18

/Users/scy/Desktop/屏幕快照 2026-02-02 的 00.52.16 上午_副本.png

242613927 发表于 2026-2-2 12:54:36

111

贴心小棉袄 发表于 2026-2-2 21:44:55

答案

ckytt 发表于 2026-2-3 08:44:46

1

Kuangre 发表于 2026-2-3 21:24:43

1. CPU 唯一认识的语言是什么语言?
Machine Code(机器码)

2. C 语言编写的源代码转换为汇编语言的过程叫什么?
编译

3. 编译型语言和解释型语言的本质区别是什么?(实现方式不同)
编译型语言是把源代码直接编译成机器码(instruction Set),从此CPU可以直接执行,不用一直转译机器码之后在进行执行
解释型语言不是直接把源代码编译成机器码(instruction Set),而是将源代码转换成中间代码(字节码),然后在由安装的解释器,逐行转换成机器码给CPU执行,效率比较慢

4.4. 在 Linux 系统上用 C 语言编译的可执行程序,是否能在 Windows 系统上执行?
不能,编译方式不同会生成不同平台的可执行文件,只有对应操作系统才能加载;同时,如果源代码使用了依赖某个系统的接口,也必须在该系统(或兼容环境)下编译和运行

5. 解释型编程语言是如何实现跨平台的?
(字节码)解释型语言能跨平台,是因为平台差异被解释器/虚拟机吸收了;在 App 场景下,只要运行时被系统预装或随 App 打包,解释型语言同样可以作为前端使用,否则就不现实。

6. 莫斯密码的原理其实是什么?
莫斯密码就像一种人类可执行的指令集:发送者按规则把明文“编译”为 .- 符号序列,接收者作为解释器按同一规则执行并还原语义,而跨平台与否取决于双方是否实现了同一套“解释器”

7. 视频中小甲鱼“故弄玄虚”的那段密文还原后是什么内容(中文)?
莫斯密码最初围绕拉丁字母设计,每一种点划组合一一对应一个字母,字母再组合成单词,从而传递语义。
逆向工程就像拿到一栋被拆得七零八落的破房子,只能靠建筑常识、材料痕迹和受力结构,一点点推断原来是什么样子,必要时甚至重建一栋“功能一样”的房子
逆向工程不是考古复原原图纸,而是用工程常识和大量经验,从残存结构中推断设计意图,并在必要时重建一个行为等价的系统。

别动我蛋糕哈 发表于 2026-2-5 19:05:13

0

123小咪 发表于 2026-2-6 12:03:29

1

咕叽咕叽789 发表于 2026-2-8 02:01:40

1

L21 发表于 2026-2-10 22:02:29

辛苦了

杨新雪 发表于 2026-2-11 12:03:09

璁$畻涓?..
鐩墠浣犳

tl123456 发表于 2026-2-11 12:33:07

鱼C有你更精彩 ^_^

SX_PIG 发表于 2026-2-12 20:59:13

{:5_101:}
页: 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 [2132] 2133 2134 2135 2136 2137 2138 2139
查看完整版本: S1E2:第一个程序 | 课后测试题及答案