1412342464 发表于 2019-9-19 08:50:38

答案

linespace 发表于 2019-9-19 09:02:48

查看参考答案

张震峰 发表于 2019-9-19 09:18:39

来支持!!!

qq5232435 发表于 2019-9-19 10:30:42

{:5_99:}

qq5232435 发表于 2019-9-19 10:41:56

Dev-C++编译器为什么我运行出来是0行代码

华弟 发表于 2019-9-19 11:12:05

哈哈哈,今天入坑。

WhaleFall6 发表于 2019-9-19 11:44:43

#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 fidAllFiles(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;

}

2717672416 发表于 2019-9-19 12:06:18

%1行代码就这么长,%100差不多就有10000多行,每行最少10个字母,那写一个程序就差不多是100000+个字母,

小甲鱼牛B 发表于 2019-9-19 13:31:58

感激大佬

树叶sy 发表于 2019-9-19 13:43:21

写完了看看答案

qvq123 发表于 2019-9-19 16:28:09

闻香识女人 发表于 2019-9-19 16:38:35

0、因为计算机只认识0和1
1、机器语言
2、编译
3、编译型语言可以直接转换成机器语言,编译的文件是可执行文件,可以直接被CPU执行,而解释型语言需要通过解释器解释之后,才能被CPU执行。
4、可以
5、
6、
7、你好,世界!

Winter_Cicada 发表于 2019-9-19 16:40:17

谢谢

550530278 发表于 2019-9-19 16:44:47

答案

SaK丶 发表于 2019-9-19 17:11:51

多谢

AS1109839875 发表于 2019-9-19 17:35:11

{:5_90:}

Crow2019 发表于 2019-9-19 21:07:26

又是充实的一天

Liuxuyu 发表于 2019-9-19 21:39:14

,,,,

小YJ 发表于 2019-9-19 22:56:19

鱼c因你更精彩

Nafiep 发表于 2019-9-19 23:05:18

{:10_279:}
页: 394 395 396 397 398 399 400 401 402 403 [404] 405 406 407 408 409 410 411 412 413
查看完整版本: S1E2:第一个程序 | 课后测试题及答案