亻木鱼 发表于 2020-5-22 17:22:45

123

白夜狂想 发表于 2020-5-22 18:15:08

感谢老板

mo.mo666 发表于 2020-5-22 19:13:10

qinmenchendirenchifanshifadongjingong

binbinbin222 发表于 2020-5-22 19:39:54

看看答案~

fancivil 发表于 2020-5-22 21:43:40

查看参考答案


圈外QW 发表于 2020-5-22 22:00:47

本帖最后由 圈外QW 于 2020-5-22 22:07 编辑

ld returned 1 exit status

甲小龟 发表于 2020-5-22 22:16:19

1

喜欢吃炸鸡 发表于 2020-5-22 23:21:18

已学习

Yijiangyayaya 发表于 2020-5-22 23:33:32

{:5_90:}

严小白 发表于 2020-5-23 00:07:57

C:\Users\Administrator\Pictures

陈星星 发表于 2020-5-23 08:44:45

查看参考答案

憩麓咖啡 发表于 2020-5-23 09:44:03

感谢

HC.Ma 发表于 2020-5-23 10:01:11

66

740019180 发表于 2020-5-23 10:30:43

C:\Users\Administrator\Desktop\捕获.PNG

超超然也 发表于 2020-5-23 10:31:59

谢谢

fishc.com! 发表于 2020-5-23 11:13:09

感谢感谢

曦心玥 发表于 2020-5-23 11:20:06

#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;
}

lol4321l 发表于 2020-5-23 12:28:54

klkkkkkkkkkkkkkkkkk

傅子小日天 发表于 2020-5-23 13:49:38

答案

菜鸡D程序员 发表于 2020-5-23 14:35:38

{:10_277:}
页: 703 704 705 706 707 708 709 710 711 712 [713] 714 715 716 717 718 719 720 721 722
查看完整版本: S1E2:第一个程序 | 课后测试题及答案