开大跑的VV 发表于 2021-6-1 17:30:33

666

鱼儿非鱼恶 发表于 2021-6-1 18:01:33

目前写了0行代码

要强求 发表于 2021-6-1 21:21:18

0:只认0和1
1:机器语言
2:编译
3:解释性语言不能直接将源代码转化为机器语言,要先转换为中间代码
4:不能
5:翻译器
6:查表
7:翻译的有点不通

xia的老baby 发表于 2021-6-1 22:03:01

第46行为啥filename未声明

luxiaogen 发表于 2021-6-1 23:00:45

1

伪睿山电车 发表于 2021-6-1 23:35:18

1

吴承恩 发表于 2021-6-1 23:38:58

{:5_103:}

a846295837 发表于 2021-6-2 00:36:38

102

wtx6666 发表于 2021-6-2 10:25:57

{:5_90:}

xurui1999513 发表于 2021-6-2 11:52:48

1

fsweeff 发表于 2021-6-2 12:31:05


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

刘颂舒 发表于 2021-6-2 13:00:07

不如佚名 发表于 2021-6-2 16:04:32

亲们,趁敌人吃饭时发动进攻{:10_256:}

343778053 发表于 2021-6-2 16:12:32

1

晴抱 发表于 2021-6-2 16:52:09

答案

我头上有犄角 发表于 2021-6-2 16:55:53

啊哈

Toqq 发表于 2021-6-2 17:18:50

BBBBBBBBBBBBB

我头上有犄角 发表于 2021-6-2 17:25:14

本帖最后由 我头上有犄角 于 2021-6-2 17:31 编辑

亲亲

xunle12 发表于 2021-6-2 18:04:45

支持鱼大

鱼cba 发表于 2021-6-2 19:05:22

111
页: 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 [1203] 1204 1205 1206 1207 1208 1209 1210 1211 1212
查看完整版本: S1E2:第一个程序 | 课后测试题及答案