mms0808 发表于 2022-1-2 10:36:19

回复

白露与猫 发表于 2022-1-2 11:32:06

ye

xyz不是坐标轴 发表于 2022-1-2 13:01:01

答案

几级石阶 发表于 2022-1-2 13:43:37

我想知道

shlrxy 发表于 2022-1-2 14:10:11

查看参考答案

了意 发表于 2022-1-2 14:43:56

为什么我运行不出来,我已经把报错的地方都改了

了意 发表于 2022-1-2 14:47:22

求大佬解答为什么我已经把报错改正了还是运行不出来。
#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;
        }
        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)
                {
                          spintf(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;
}

Kamuchi 发表于 2022-1-2 15:14:56

写完了看答案

XD-16 发表于 2022-1-2 15:15:11

{:5_102:}

blackmanbar 发表于 2022-1-2 15:20:43

0:因为计算机只认识0和1的机器码
1:机器语言
2:编译
3:编译型语言需要从汇编语言变成机器语言,而解释型语言直接转换成机器语言
4:可以
5:直接转换成机器语言可以在各个平台使用
6:将对应的字符组合查表翻译出来
7:亲们吃饭是发动机

poulSu 发表于 2022-1-2 16:39:01

nb

lvdong0626 发表于 2022-1-2 17:01:46

134355

LYG.fishc 发表于 2022-1-2 17:18:08

总共0行代码(不知怎么上传照片)

LYG.fishc 发表于 2022-1-2 17:24:31

我自己 手敲的结果 显示 总共0行代码
复制了一份还是 显示 0行代码(用的Dev)
是答案 不对嘛

2747488604 发表于 2022-1-2 19:14:43

感谢鱼爷!

zhangxuhui45 发表于 2022-1-2 19:31:17

11

尹框 发表于 2022-1-2 19:55:06

课后测试题及答案

pwjpj52 发表于 2022-1-2 21:12:50

bbay 发表于 2022-1-2 21:31:31

看看测试题答案

叶旨亿 发表于 2022-1-2 21:56:01

222222
页: 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 [1503] 1504 1505 1506 1507 1508 1509 1510 1511 1512
查看完整版本: S1E2:第一个程序 | 课后测试题及答案