18178191160 发表于 2021-10-10 13:21:42

1

游戏王fb 发表于 2021-10-10 14:15:40

6

ZYM0921 发表于 2021-10-10 14:23:40

{:5_102:}

xboxhao 发表于 2021-10-10 14:26:45

呃呃呃呃呃呃呃呃呃呃呃呃呃呃

封文 发表于 2021-10-10 15:26:29

已完成本节课课后作业

MIfan1 发表于 2021-10-10 15:28:51

1

一百分 发表于 2021-10-10 16:02:44

dianan

programmaster 发表于 2021-10-10 16:15:46

hhhhhh

阿卡姆 发表于 2021-10-10 16:29:13

118

LUZIAN 发表于 2021-10-10 16:33:29


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

jocichen 发表于 2021-10-10 16:41:49

终于抄完了

jocichen 发表于 2021-10-10 16:55:34

甲鱼甲鱼 我可以成功运行程序 但是为啥上面写着"你总共运行了0行代码"而不是102行啊??

阿为 发表于 2021-10-10 17:13:55

haoye

尴尬的偷心贼 发表于 2021-10-10 17:41:29

甲鱼我来晚了

dnasfnasn 发表于 2021-10-10 18:03:52

一直报错啊

黑暗中的潜逃者 发表于 2021-10-10 18:05:01

0.因为计算机只能识别二进制

药神8848 发表于 2021-10-10 18:42:58

人麻了

萧碧宰治 发表于 2021-10-10 18:52:05

学习之魂熊熊燃烧

alyce 发表于 2021-10-10 19:00:36

0.计算机指认机器语言

1.机器语言

2.编译

3.编译语言可以直接转换成机器语言,解释性语言需要解释器翻译才能转换成机器语言

4.可以

5.通过解释器

6.查表

7.QINMENCHENDIRENCHIFANSHIFADONGJINGONG
亲们趁敌人吃饭时发动进攻

8.

lantine 发表于 2021-10-10 19:27:21

C:\Users\86459\Desktop\屏幕截图 2021-10-10 192621.png
页: 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 [1411] 1412 1413 1414 1415 1416 1417 1418 1419 1420
查看完整版本: S1E2:第一个程序 | 课后测试题及答案