Angelina_Jolie 发表于 2021-11-15 15:52:52

1

18944190779 发表于 2021-11-15 16:10:14

1

琰ER 发表于 2021-11-15 20:01:08

看答案

kbht 发表于 2021-11-15 20:27:59

66666666666666

Jacka1 发表于 2021-11-15 20:31:34

11

C入坑 发表于 2021-11-15 20:43:34

为啥没有注释

卓颖 发表于 2021-11-15 21:01:34

#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 findAIICodes(const char *path)
{
        struct _finddata_t fa;
        long handle;
        char dthePath, targe;
       
        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);
                          findAIICodes(thePaath);
                          findALLDirs(thePath);
                        }      
                }while (_findnext(handle, &fa) == 0);
               
                _findclose(handle);
        }
       
        int main()
        {
                char path =".";
               
                printf("计算中...\n");
               
                fingAIICodes(path);
                findALLDirs(path);
               
                printf("目前你总共写了 %1d 行代码!\n\n", total);
                system("pause");
               
                return 0;
        }

昭昭超 发表于 2021-11-15 21:40:58

爱了

zuli1230 发表于 2021-11-15 21:56:57

s

栤焰 发表于 2021-11-15 22:22:59

哈哈

cd2480 发表于 2021-11-15 22:50:55

ww

羊阳杨Yang 发表于 2021-11-15 22:52:27

才152........加油!

1657875262 发表于 2021-11-16 01:46:28

1

dtwangchao 发表于 2021-11-16 06:09:53

看看答案

库哟 发表于 2021-11-16 07:13:22

1

CFree_h 发表于 2021-11-16 08:18:40

重要的

zzzzwwwwxxxx 发表于 2021-11-16 10:13:52

1

miclemicle 发表于 2021-11-16 11:19:43

woxiangyap

yy_Duren 发表于 2021-11-16 11:43:34

琰ER 发表于 2021-11-16 13:43:30

我使用VSC学c语言,第一个课后作业两个版本的都不行,这是为什么啊
页: 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 [1460] 1461 1462 1463 1464 1465 1466 1467 1468 1469
查看完整版本: S1E2:第一个程序 | 课后测试题及答案