PrtSc 发表于 2021-3-24 12:58:06

{:5_106:}

1271128065 发表于 2021-3-24 13:11:29

查看参考答案

3031669774 发表于 2021-3-24 13:15:23

DAA

小叮当来了 发表于 2021-3-24 13:33:07

未能识别#include<io.h>

RzeroeE 发表于 2021-3-24 14:53:32

十分感谢

小3很Qpen 发表于 2021-3-24 15:14:10

6666

小夜さよ 发表于 2021-3-24 15:22:26

回复

cxk233 发表于 2021-3-24 15:24:37

{:5_109:}

——careless 发表于 2021-3-24 16:16:34

期待

a4214513 发表于 2021-3-24 16:28:06

1111111111111111111111111111111111111111

whycon 发表于 2021-3-24 16:33:20

计算中...
The path gvfs is wrong!
目前你总共写了 46316行代码!

whycon 发表于 2021-3-24 16:36:24

whycon 发表于 2021-3-24 16:33
计算中...
The path gvfs is wrong!
目前你总共写了 46316行代码!

为什么 复制和自己抄写 都会出现“The path gvfs is wrong!”

吾凡而不殆 发表于 2021-3-24 17:32:27

啊嘞嘞

烧药 发表于 2021-3-24 17:37:27

查看参考答案

莫云遥 发表于 2021-3-24 18:06:33

D:\onedrive\桌面

zby。。。 发表于 2021-3-24 19:31:56

只能识别二进制

~芄兰~ 发表于 2021-3-24 20:08:41


#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-3-24 20:30:35

..

sanjicaihua 发表于 2021-3-24 21:12:35

E

安上可爱 发表于 2021-3-24 21:17:57

666
页: 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 [1129] 1130 1131 1132 1133 1134 1135 1136 1137 1138
查看完整版本: S1E2:第一个程序 | 课后测试题及答案