yangruidonglin 发表于 2020-12-8 14:18:20

666

雨后天晴123 发表于 2020-12-8 15:07:04

qwe

七叔 发表于 2020-12-8 16:29:27

f

manto- 发表于 2020-12-8 17:02:50

1

顾小c 发表于 2020-12-8 17:38:52

第一个程序 | 课后测试题及答案 [修改]

晒尾巴的狐狸 发表于 2020-12-8 20:29:45

1

ahf 发表于 2020-12-8 20:43:53

勤奋的小白兔 发表于 2020-12-8 21:53:14

1

WGB1213 发表于 2020-12-8 21:55:28

对照出一堆字母不知道什么含义

leihongwei93 发表于 2020-12-8 22:26:06

#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>

#define MAX 256

long total;

int countLines(const char *filename);
int isCode(const char *filename);
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;
}

int isCode(const char *filename)
{
      int length;

      length = strlen(filename);
      
      if (!strcmp(filename + (length - 2), ".c"))
      {
                return 1;
      }
      else
      {
                return 0;
      }
}

void findAllDirs(const char *path)
{
      DIR *dp;
      struct dirent *entry;
      struct stat statbuf;

      if ((dp = opendir(path)) == NULL)
      {
                fprintf(stderr, "The path %s is wrong!\n", path);
                return;
      }

      chdir(path);
      while ((entry = readdir(dp)) != NULL)
      {
                lstat(entry->d_name, &statbuf);

                if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name))
                        continue;

                if (S_ISDIR(statbuf.st_mode))
                {
                        findAllDirs(entry->d_name);
                }
                else
                {
                        if (isCode(entry->d_name))
                        {
                              total += countLines(entry->d_name);
                        }
                }
      }

      chdir("..");
      closedir(dp);
}

int main()
{
      char path = ".";

      printf("计算中...\n");

      findAllDirs(path);

      printf("目前你总共写了 %ld 行代码!\n\n", total);

      return 0;
}

诺一WY 发表于 2020-12-8 22:53:32

0.只识别0和1
1.机器语言
2.翻译
3.编译型语言不用翻译器,机器课直接读懂;解释型语言需要翻译器
4.可以
5.翻译器
6.
7.

langou212 发表于 2020-12-9 08:22:18

danan

米洛 发表于 2020-12-9 09:39:17

看一看结果

Aruuuu 发表于 2020-12-9 10:10:45

0、因为计算机只认二进制
1、二进制
2、编译
3、解释型语言先转换成代码块,经解释器解释成机器语言,一行一行的解释
4、不行

瞪太阳 发表于 2020-12-9 10:32:01

0.计算机只看得懂二进制。
1.机器语言。
2.编译
3.编译型语言编译后CPU可直接执行,解释型语言要通过解释器在由CPU执行。
4.在Linux系统上的程序大多数都不能在Windows系统上执行。
5.编译器需依靠平台,而解释型语言依靠不同平台的解释器就可以实现跨平台。

清之风 发表于 2020-12-9 12:05:03

{:10_257:}{:10_258:}好好学习

Yep要谦虚 发表于 2020-12-9 15:12:21

1

番茄laosp 发表于 2020-12-9 16:22:25

感觉还行

V梦狼 发表于 2020-12-9 16:43:30

踩踩踩

新鲜的朽木 发表于 2020-12-9 16:56:23

qinmen
页: 965 966 967 968 969 970 971 972 973 974 [975] 976 977 978 979 980 981 982 983 984
查看完整版本: S1E2:第一个程序 | 课后测试题及答案