learninghappy 发表于 2020-2-28 22:53:03

学习了!!

laicklee 发表于 2020-2-28 23:12:09

{:10_257:}

一枚枕头 发表于 2020-2-28 23:13:52

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

#define MAX

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
                {
                        printf(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("目前你总共写了%d行代码!\n\n",total);
        system("pause");

        return 0;



}

1报错:fatal error C1083: Cannot open include file: 'direct.h': No such file or directory

laughingboy90 发表于 2020-2-28 23:48:11

答案

CutAllTrees 发表于 2020-2-29 05:32:28

hh

风烟流年 发表于 2020-2-29 08:13:10

haha

843045159 发表于 2020-2-29 09:31:49

{:5_105:}

问问we 发表于 2020-2-29 10:15:16

0.二进制
1.机器语言
2.
3.
4.能
5.解释器
6.

muyisheng 发表于 2020-2-29 10:49:27

0.只认识0,1
1.汇编语言
2.编译
3.
4.可以
5.源代码相同,编译器编译出来的二进制文件就会实现相同的功能
6.用点和杠来传递信息
7.

Chuancyyang 发表于 2020-2-29 12:10:06

{:10_277:}

LJK5423615 发表于 2020-2-29 12:13:03

来看答案啦

yingchui 发表于 2020-2-29 12:13:42


放慢脚步 发表于 2020-2-29 12:14:04

学习一下

Guarens 发表于 2020-2-29 12:41:38

瞄一眼

孤风残墨 发表于 2020-2-29 13:29:47

1234

EDX 发表于 2020-2-29 13:30:15



Dreaming灬 发表于 2020-2-29 13:56:53

{:5_107:}

17606653809@163 发表于 2020-2-29 14:13:09

答案

Corona丶 发表于 2020-2-29 14:22:49

&#128031;老师加油

R.XT 发表于 2020-2-29 14:28:43

0.计算机只懂二进制
1.机器语言
2.编译
3.解释型语言需要经过解释器
4.可以
5.
6.编码和解码
7.
页: 588 589 590 591 592 593 594 595 596 597 [598] 599 600 601 602 603 604 605 606 607
查看完整版本: S1E2:第一个程序 | 课后测试题及答案