threnody 发表于 2024-6-12 17:42:47

写完了来看答案

ZJX11221 发表于 2024-6-12 21:46:18

#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 = _findfrist(strcat(thePath, "/*"), &fa)) == -1L)
        {
                fprintf(stderr, "The path %s is wrong!\n", path);
                return;
        }
        do
        {
                if (!strcump(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;

}

ERICMIKE 发表于 2024-6-13 09:09:41

良心小甲鱼!!!

哈啊哈a 发表于 2024-6-13 13:00:00

1

一次大胆的决定 发表于 2024-6-13 16:51:27

{:5_95:}

变成鱼CC 发表于 2024-6-13 23:05:54

1

不度玉门关24 发表于 2024-6-13 23:44:43

..

yingzheng 发表于 2024-6-14 18:56:48

66

wsgdmsj 发表于 2024-6-14 22:25:51

完成了

一只小鸮 发表于 2024-6-15 13:21:12

打完了

dycss 发表于 2024-6-15 13:48:44

damn bro

LwX$$ 发表于 2024-6-15 13:53:30

看看答案

猪pig桑 发表于 2024-6-15 15:19:49

敲完

月空sora 发表于 2024-6-16 11:35:19

查看答案

2316783264 发表于 2024-6-16 14:19:55

111

0.3 发表于 2024-6-17 03:18:40

0. 只看懂010101
1.汇编语言 即101010
2.编译
3.编译型语言是吧文件一次性编译完成汇编语言再编译成机器语言然后CPU执行,解释性语言是编译一次,CPU执行一条
4.可以
5.可以生成字节码,不同平台有不同的解释器,解释器可以编译字节码

JOSEPHSYT 发表于 2024-6-17 09:31:11

打卡

curry0613 发表于 2024-6-18 10:20:24

1

syjcss 发表于 2024-6-18 13:16:31

1

Yuxin7 发表于 2024-6-18 14:47:58

查看参考答案
页: 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 [2032] 2033 2034 2035 2036 2037 2038 2039 2040 2041
查看完整版本: S1E2:第一个程序 | 课后测试题及答案