1005439991 发表于 2020-5-11 21:49:38

为什么我是0行

Mu01 发表于 2020-5-11 22:19:40

加油

WrenchZ 发表于 2020-5-11 22:48:10


#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#定义MAX 256

总长

int countlines(const char * 文件名);
void findAllcodes(const char * path);
void findAllfiles(const char * path);

int countlines(const char *文件名)
{
         文件* fp;
               int count = 0;
               温度
               
               如果((fp = fopen (文件名,"r")) == NULL)
               {
                       fprintf(stderr,"无法打开文件:%s \ n",文件名);
                       返回0
               }
               
               而((temp = fgetc(fp))! = EOF)
               {
                       如果(temp =='\n')
                       {
                               数++;
                          }
                  }
                  
                  fclose(fp);
                  
                  返回计数;
}

无效findAllcodes(const char * path)       
{
        struct_finddate_t fa;
        长柄
        char thePath , target ;
       
        strcpy(thepath, path) ;
        if((句柄=_findfirst(strcat(thePath,"/*.c"),&fa))! = -1L)
        {
                做
                {
                        sprintf(target,"%s/%s",path,fa.name);
                        总数+ = countLines(目标);
                } 同时(_findnest(handle,&fa)== 0);
        }
       
        _findclose(handle);
}

无效findALLDirs(const char * path)
{
        struct_finddata_t fa;
        长柄
        char thePath ;
       
        strcpy(thePath,path);
        if((句柄=_findfirst(strcat(thePath."/*")&fa))== -1L )
        {
                fprintf(stderr,"%s路径错误!\n",path);
                返回;
        }
       
        做
        {
                if(!strcmp(fa.name,"。")||!strcmp(fa.name," ..")))
                继续
               
                if(fa.attrib ==_A_SUBDIR)
                {
                        sprintf(thePath,"%s/%s",path,fa.name);
                        findAllcodes(thePath);
                        findALLDirs(thePath);
               
                }
       } 同时(_findnest(handle,&fa)== 0) ;
       
       _findclose(handle);
}

int main()
{
        char path = "0";
       
        printf("计算中...\n");
       
        findAllCodes(path);
        findALLDirs(path);
       
        printf("目前你总共写了%1d行代码!\ n \ n",总计);
        系统("暂停");
       
        返回0;
}

zhoukai0707 发表于 2020-5-12 09:15:06

1

LUNA19 发表于 2020-5-12 09:47:41

{:5_102:}{:5_102:}{:5_102:}

pythonmt111 发表于 2020-5-12 10:19:08

1

835465797 发表于 2020-5-12 10:19:59

答案

unwbd 发表于 2020-5-12 10:25:30

辛苦了

1106722202 发表于 2020-5-12 10:47:35

123

林太郎 发表于 2020-5-12 12:34:20

来看答案啦

梦仔睡醒了吗 发表于 2020-5-12 12:57:55

1

y1361281921 发表于 2020-5-12 13:25:51

打代码打的要绝望了

XJQXXX 发表于 2020-5-12 13:32:46

1

啦啦啦aa 发表于 2020-5-12 13:33:57

1

2020.5.11 发表于 2020-5-12 15:21:53

检查作业

2770476913 发表于 2020-5-12 17:20:00

.

wei了学习 发表于 2020-5-12 17:40:57

打完好累。。。

Connie_Chueng 发表于 2020-5-12 18:38:09

谢谢楼主~

yrzuimei 发表于 2020-5-12 19:29:17

因为他只能设别机器语言 01

打翻酱油醋 发表于 2020-5-12 19:46:28

.
页: 692 693 694 695 696 697 698 699 700 701 [702] 703 704 705 706 707 708 709 710 711
查看完整版本: S1E2:第一个程序 | 课后测试题及答案