FireQ 发表于 2020-3-16 13:31:16

感谢

ACTEN20645 发表于 2020-3-16 13:45:54

好吧,我认了,我就算超也能超出一堆错误来,主要是少了空格和转换行

GloryTime 发表于 2020-3-16 13:52:48

目前你总共写了8行代码

听自己的话 发表于 2020-3-16 14:31:35

学到了{:5_109:}

aiyahu 发表于 2020-3-16 14:33:16

学习 学习

li1114382933 发表于 2020-3-16 15:03:57

...

ml921000 发表于 2020-3-16 15:21:04

1

请叫我神补刀 发表于 2020-3-16 15:32:03

来了来了

传阅 发表于 2020-3-16 16:17:47

感谢楼主

Caesarzz 发表于 2020-3-16 16:32:34

亲们趁敌人吃饭时发动进攻

冰红茶茶 发表于 2020-3-16 16:35:38

查看参考答案

qq17510514386 发表于 2020-3-16 16:52:16

666666666666666666

shirin 发表于 2020-3-16 17:04:51

1

蝙蝠让我学习 发表于 2020-3-16 17:23:39


#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 min()
{
        char path = ".";
       
        printf("¼ÆËãÖD...\n");
       
        findALLCodes(path);
        findALLDirs(path);
       
        printf("ĿǰÄã×ü12D′áË %ld DD′úÂ룡\n\n",total);
        system("pause");
       
        return 0;
}

smg123456 发表于 2020-3-16 17:50:20

谢谢

xioami 发表于 2020-3-16 17:51:57

da

我想学习unity 发表于 2020-3-16 18:28:57

感谢楼主无私奉献

daiyifan 发表于 2020-3-16 18:42:35

谢谢

zhangzachery 发表于 2020-3-16 18:57:59

本帖最后由 zhangzachery 于 2020-3-16 19:00 编辑

打卡了

琳小猪猪 发表于 2020-3-16 19:00:50

RE: S1E2:第一个程序 | 课后测试题及答案
页: 622 623 624 625 626 627 628 629 630 631 [632] 633 634 635 636 637 638 639 640 641
查看完整版本: S1E2:第一个程序 | 课后测试题及答案