AndicLessemis 发表于 2024-7-25 13:37:06

完成啦
以为写出来是个啥呢
没想到是个行数检测器哈哈哈

AndicLessemis 发表于 2024-7-25 13:42:27

AndicLessemis 发表于 2024-7-25 13:37
完成啦
以为写出来是个啥呢
没想到是个行数检测器哈哈哈

为什么显示是0行。。。

quansy 发表于 2024-7-25 14:57:46

11111

onbody 发表于 2024-7-25 15:01:10

#include <io.h>
#include <direct.h>
#inculde <stdio.h>
#inculde <stdlib.h>
#inculde <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 files: %s\n", filename);
                        return 0;
           }
          
          
           while ((temp = fgetc(fp)) != EOF)
                {
                        if(temp == '\n')
                        {
                                   count++;
                                }
           }
          
          
           fclose(fp);
          
          
           return count;
}

void findALLDirs(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;
}

wenchenga 发表于 2024-7-25 16:15:15

0

superyumiao 发表于 2024-7-25 18:15:38

a

Eliott28 发表于 2024-7-26 01:13:02

11

FoxyC 发表于 2024-7-26 14:38:44

0只能看懂计算码
1计算码
2编译
3?
4可以
5?
6特定密码组合与字符一一对应
7…

艺术大湿 发表于 2024-7-26 14:40:08

1

学程序真快乐 发表于 2024-7-26 16:58:09

1

kongchen 发表于 2024-7-26 18:39:41

5

xiaohao6538 发表于 2024-7-26 19:39:50

答案答案

奋斗中的鱼 发表于 2024-7-26 20:27:21

okok~

三体人的智子 发表于 2024-7-26 21:40:59

0:傻。只认识1和0
1:机器语言
2.编译
3.一个整体。一个是一行一行
4.不行!

6
编译

1286602907 发表于 2024-7-26 21:52:07

{:5_90:}

myl2006 发表于 2024-7-27 10:24:11

请问为什么使用VS无法运行?{:10_266:}

angwww 发表于 2024-7-27 11:51:48

计算机只会读懂自己的语言,根据指令运行

测试测试 发表于 2024-7-27 17:55:51

{:10_277:}

WymanChan 发表于 2024-7-28 12:01:17

^_^

皓月语 发表于 2024-7-28 17:48:52

1
页: 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 [2042] 2043 2044 2045 2046 2047 2048 2049 2050 2051
查看完整版本: S1E2:第一个程序 | 课后测试题及答案