帝国绅士 发表于 2019-10-1 21:52:58

0.因为它只认识0和1
1.机器语言
2.额
3.编译型语言:源代码编译成机器语言,CPU可以直接执行
.解释型语言:将源代码发给解释器,在有解释器逐条发给CPU来执行
4.能
5.每次都要先发给解释器
6.把能看懂的文字化成各种点,横。接收方再翻译过来。
7.qinmenchendirenchifanshifadongjingong
???{:5_99:}

修电脑的大叔 发表于 2019-10-1 22:22:49

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

超链接自来也 发表于 2019-10-1 22:25:47

哈哈哈

FateKey 发表于 2019-10-1 22:40:16

很不错,已经手打完程序了

HenGwU 发表于 2019-10-1 22:46:30

大一新生

游游游时 发表于 2019-10-1 22:49:51

0.只能识别01
1.机器语言
2.编译
3.转化为指令的形式不同
编译型语言 源代码-汇编语言 CPU
解释型语言-中间代码-解释器-CPU
4.可以,或只需要稍加修改
5.解释器与中间代码对应,只需要合适的解释器便可以执行程序
6.编码,解码(?(查表

findALLDirs 没有申明((不知道哪里出问题了

ssqqrr12138 发表于 2019-10-1 23:26:56

108

15711566517 发表于 2019-10-1 23:30:38

回复

Henderson 发表于 2019-10-2 00:52:46

感谢楼主

SAFFo 发表于 2019-10-2 09:44:18

嘿嘿嘿

生机疯魔 发表于 2019-10-2 10:28:06

答案

钱大帅 发表于 2019-10-2 11:14:26

力挺楼主

ljx11714472 发表于 2019-10-2 11:39:31

看答案

mox404 发表于 2019-10-2 12:16:43

0

Henry2001 发表于 2019-10-2 15:01:45

大学的第一堂课,希望能有个好的过程

李里ss 发表于 2019-10-2 15:21:47

啊啊

李里ss 发表于 2019-10-2 15:24:50

测试题答案

纱雾Sagiri 发表于 2019-10-2 15:51:02

看看

KJS12 发表于 2019-10-2 16:44:24

请问最终答案是否和我的相似呢?

mk加油 发表于 2019-10-2 16:51:43

Devc++怎么操作-
页: 408 409 410 411 412 413 414 415 416 417 [418] 419 420 421 422 423 424 425 426 427
查看完整版本: S1E2:第一个程序 | 课后测试题及答案