pangd 发表于 2020-12-12 12:58:02

C:\Users\Pangd\Desktop\企业微信截图_16077490161480.png

薛定谔的发发 发表于 2020-12-12 13:55:52

写完了 看看答案

是猫爪啊 发表于 2020-12-12 16:09:37

打卡

嘎嘎敲代码 发表于 2020-12-12 17:19:48


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

Hurricane_ 发表于 2020-12-12 18:22:33

没看明白啊

落华 发表于 2020-12-12 18:24:31

打了半天
累死了

kaysar 发表于 2020-12-12 18:28:04

在vs2019中出现了好多错误

a246300646 发表于 2020-12-12 18:38:41

冲冲冲

superman24 发表于 2020-12-12 19:14:28

2222222

c_sir 发表于 2020-12-12 21:39:13

我要窥破天机嘞{:10_256:}

叫爸爸.. 发表于 2020-12-12 22:42:17

E:\360MoveData\Users\Maibenben\Desktop

c语言程序猿 发表于 2020-12-12 23:49:46

22

BingHongNi 发表于 2020-12-13 07:01:28

s

Marilyn 发表于 2020-12-13 08:45:43

感谢楼主无私奉献!

绿意泛 发表于 2020-12-13 09:53:51

答案

QCinta 发表于 2020-12-13 10:33:00

0.因为它只懂二进制的0和1
1.机器语言
2.编译
3.效率的高低
4.可以
5.是将源代码转换成中间代码,然后发送给解释器
6.查表
7.亲们,趁敌人吃饭时发动进攻

aa1755170018 发表于 2020-12-13 14:01:58

感谢!

杨总Q3 发表于 2020-12-13 15:18:36

0:计算机里面都是二进制。
1:机器语言
2:编译
3:?
4:能
5:不太清楚
6:查表
7:

ChaoM 发表于 2020-12-13 15:47:50

26

短寿 发表于 2020-12-13 15:48:17

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