T110 发表于 2024-3-16 16:38:43

答案

GotohRyo 发表于 2024-3-16 18:26:48

1

theaha 发表于 2024-3-16 19:11:33

{:10_249:}

theaha 发表于 2024-3-16 19:12:17

{:5_103:}

yimo12 发表于 2024-3-16 19:20:15

错误

newbie12 发表于 2024-3-16 21:45:44

答案

混子小棕熊 发表于 2024-3-16 22:40:35

学习

haerin 发表于 2024-3-16 23:17:17

1

feiersuojiye 发表于 2024-3-16 23:28:32

图片地址怎么写啊

hmz 发表于 2024-3-17 10:22:33

1

YYLjerry 发表于 2024-3-17 10:38:37

查看答案

fishcZJJ 发表于 2024-3-17 15:22:46

查看参考答案

kknmsl 发表于 2024-3-17 17:33:15

QAQ

295504048 发表于 2024-3-17 19:07:56

很好

myhpbug 发表于 2024-3-18 15:01:10

1

1753344540 发表于 2024-3-18 15:13:13

0.计算机只能识别0和1

1.机器语言

2.编译

3.是否需要经过翻译器翻译

4.应该能

5.将源码转换成中间代码由cpu翻译

6.莫斯编译表(查表)

7.没想出来
Finmen
Chend
Irenc
hifan
shif
adong
jingo
ng

WhateverLF 发表于 2024-3-18 15:50:19

本帖最后由 WhateverLF 于 2024-3-18 15:54 编辑

0. 为什么我们说计算机其实是“二傻子”?
0:因为计算机只能看懂机器语言,其他语言需要进行转换成机器语言才能被计算机所识别

1. CPU 唯一认识的语言是什么语言?
1:机器语言

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

3. 编译型语言和解释型语言的本质区别是什么?
3:编译型语言是整体编译好后供给cpu执行,而解释型语言是一边编译一边执行,可能执行代码时有的代码还没有进行编译。(做好一桌菜吃&烫火锅边烫边吃)

4. 在 Linux 系统上用 C 语言编译的可执行程序,是否能在 Windows 系统上执行?
4:可以,c语言的特点之一就是可移植性高
4(订正):不能。因为可执行文件在执行之前,操作系统要有一些准备工作,因为不同的操作系统,准备工作是不同的,所以可执行文件的格式不完全相同。比如 Windows 上大部分可执行文件为 PE 格式,而 Linux 上大部分可执行文件为 ELF 格式。格式不同导致了不同的可执行文件无法跨平台直接使用

5. 解释型编程语言是如何实现跨平台的?
5:不清楚
5(订正):解释型编程语言为每个操作系统专门定制一个解释器作为中转,因此解释器只需提供一个统一的入口即可

6. 莫斯密码的原理其实是什么?
6:查手册进行翻译

7. 视频中小甲鱼“故弄玄虚”的那段密文还原后是什么内容(中文)?
7:{:10_257:}有点懒不爱去查,因为已经看到第二节课了qvq

white_h 发表于 2024-3-18 20:12:31

#define _CRT_SECURE_NO_WARNINGS 1
#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;
}

运行结果:
计算中...
The path . is wrong!
目前你总共写了 0 行代码!
(这是对的吗)

080209 发表于 2024-3-18 21:12:43

感谢

Astleya 发表于 2024-3-18 22:37:12

1
页: 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 [2015] 2016 2017 2018 2019 2020 2021 2022 2023 2024
查看完整版本: S1E2:第一个程序 | 课后测试题及答案