慕言·GXH 发表于 2020-5-18 16:12:34

???...
??????? 0 ???!

请按任意键继续. . .

--------------------------------
Process exited after 1.64 seconds with return value 0
请按任意键继续. . .

余年余生 发表于 2020-5-18 16:28:17

有用

胡大姐 发表于 2020-5-18 17:58:31

{:5_90:}

原宿FJF 发表于 2020-5-18 18:42:33

回复

kdd12345 发表于 2020-5-18 18:52:07

{:5_100:}

Npccc 发表于 2020-5-18 20:06:39

{:10_277:}

只若敷衍 发表于 2020-5-18 21:32:38

#include<io.h>
#include<direct.h>
#include<stdlib.h>
#include<stdio.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;
}
编译不过呢

fklystd 发表于 2020-5-18 22:32:07

我做完作业了

StarSeeker 发表于 2020-5-18 23:56:38

1

王斯文 发表于 2020-5-19 08:25:57

看看答案

管漂亮 发表于 2020-5-19 08:33:39

{:5_103:}

hubinghuandi 发表于 2020-5-19 09:18:44

正想知道

梦新小生 发表于 2020-5-19 10:15:47

萌新报道

江野星河 发表于 2020-5-19 11:16:37

哈哈

dusir1989 发表于 2020-5-19 12:17:14

...

clearlove10 发表于 2020-5-19 13:11:06

aaaa

Kyrain 发表于 2020-5-19 13:20:47

{:5_109:}

$hiro 发表于 2020-5-19 15:03:55

6666

GJtoca 发表于 2020-5-19 16:04:21

xiexie

newchexinyi 发表于 2020-5-19 16:40:13

页: 698 699 700 701 702 703 704 705 706 707 [708] 709 710 711 712 713 714 715 716 717
查看完整版本: S1E2:第一个程序 | 课后测试题及答案