雪与鱼 发表于 2021-1-17 16:17:47

对答案,学习C语言的第一次作业。

kk在努力进步 发表于 2021-1-17 16:32:05

123
csasc

张文豪 发表于 2021-1-17 16:35:02

f

投入就放过 发表于 2021-1-17 17:14:21


#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 = _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 = ".";
       
        print("计算中...\n");
       
        findALLCodes(path);
        findALLDris(path);
       
        printf("目前你总共写了%ld行代码!\n\n",total);
        system("pause");
       
        return 0;
}
你好请问一下为什么后面会出现      
D:\c语言(小甲鱼)\课1第一个程序\collect2.exe           ld returned 1 exit status?

1452310752 发表于 2021-1-17 17:21:20

AA

Ay_Ger 发表于 2021-1-17 17:40:37

报错了一万个,单词和符号都没错啊,为啥报错呢,就是空格与复制的不太一样,但是又不知道每个打多少个空格{:10_269:}

bo~niu 发表于 2021-1-17 18:00:13

答案

依and喵 发表于 2021-1-17 18:01:11

答案

沙河老街饶治 发表于 2021-1-17 18:11:59

c

02创时代 发表于 2021-1-17 18:27:38

答案

银河搭车客 发表于 2021-1-17 18:39:25

0.无法识别高级语言
1.计算机语言
2.编译
3.解释型语言要先把语言转化为字节码,再发送给解释器进行翻译
4.可以
5.解释器
6.根据莫斯编码表翻译
7.亲们趁敌人吃饭时发动进攻

月胧二 发表于 2021-1-17 18:44:33

来看答案了

北邮小渣渣 发表于 2021-1-17 18:49:56

{:5_109:}

没有才华 发表于 2021-1-17 19:13:31

1

jackyue 发表于 2021-1-17 19:41:47

nan

M狍子M 发表于 2021-1-17 20:22:02

1、机器语言2、编译3、解释型:不能生成可独立执行的文件,编译型:目标程序可以脱离其语言环境独立执行
4、能在Windows系统上执行5、通过解释器6、查表

黑铁V 发表于 2021-1-17 20:26:41

1

foreveren 发表于 2021-1-17 20:47:51

课后测试题答案

黑铁V 发表于 2021-1-17 21:03:12

1

1158038110 发表于 2021-1-17 21:19:09

D:\小甲鱼\课后习题
页: 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 [1017] 1018 1019 1020 1021 1022 1023 1024 1025 1026
查看完整版本: S1E2:第一个程序 | 课后测试题及答案