攻城机械军团 发表于 2019-6-11 22:26:08

谢谢

Carygo 发表于 2019-6-11 22:30:43

868行{:10_256:}

zjw96816 发表于 2019-6-11 23:07:20

1

1191673531 发表于 2019-6-12 00:27:25

谢谢小甲鱼

微尘_166 发表于 2019-6-12 12:00:10

方法

Ashin的c 发表于 2019-6-12 12:05:43

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

yoooo丶 发表于 2019-6-12 12:17:21

查看参考答案

wangjiale 发表于 2019-6-12 13:31:36

101行代码 C:\Users\Administrator\Desktop

口是心非8090 发表于 2019-6-12 13:58:00

0,因为计算机没有思考能力,是按照人的命令执行
1,机器语言
2,编译
3,编译型语言是编译好执行,解释型语言是运行时编译
4,可以
5,解释型语言通过解释器实现跨平台
6,摩斯密码的原理是将不同的字母映射成对应的信号段,反之,拿到信号段,然后转换成字母,通过字母组合形成文本
7,亲们趁敌人吃饭时发动进攻

IceDream1024 发表于 2019-6-12 15:07:08

{:5_90:}

繁星星 发表于 2019-6-12 15:48:22

dududadadang 发表于 2019-6-12 17:13:02

看看答得对不

COLWN 发表于 2019-6-12 21:21:47

第次一没抄对,第二次测试完显示94行代码

ctulyar 发表于 2019-6-12 21:34:27

love Fishc

一只小小的芋圆 发表于 2019-6-12 21:42:30

0计算机只能识别0和1
1机器语言
2编译
3编译型语言可直接将代码转化为机器语言,而解释型语言要将代码转化为中间代码
4否
5解释型编程语言将代码转换层中间代码,再发送给解释器,由解释器转化为机器语言
6通过与摩斯密码表比对翻译
7亲们趁敌人吃饭时进攻

Jjkkll987987 发表于 2019-6-12 22:09:15

哦耶。好多不会,记下来了{:5_109:},要加油啊

chinesevic 发表于 2019-6-12 22:18:55

谢谢分享!!!!                        

卡尔书院 发表于 2019-6-12 22:30:23

1

HoRizon.cc 发表于 2019-6-12 23:28:06

哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈

sunping 发表于 2019-6-12 23:48:42

看看
页: 302 303 304 305 306 307 308 309 310 311 [312] 313 314 315 316 317 318 319 320 321
查看完整版本: S1E2:第一个程序 | 课后测试题及答案