lxMission 发表于 2022-9-19 22:50:18

1

llwj520 发表于 2022-9-19 23:09:11

1

Dreamta左丘 发表于 2022-9-20 07:53:59

测了一下只有0行代码,看看咋回事

xianyv2414 发表于 2022-9-20 08:54:07

答案

隆美尔 发表于 2022-9-20 09:32:50


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

        return 0;
}

风城 发表于 2022-9-20 10:04:55

测试题答案

echo.c 发表于 2022-9-20 10:08:16

0、只能直接识别二进制
1、机器语言
2、编译
3、编译型语言通过编译产生程序,解释型语言通过解释运行不产生.exe
4、可以,C语言可移植性高
5、通过解释器
6、二进制

莲江5 发表于 2022-9-20 10:27:04

不会

音乐人冰果 发表于 2022-9-20 11:25:08

Hcney 发表于 2022-9-20 12:20:32

.

Dht031230 发表于 2022-9-20 13:00:24

.

redghost158 发表于 2022-9-20 13:15:24

        鱼C有你更精彩^_^

forctrl 发表于 2022-9-20 13:17:54

66666666666666

少先队员马叔叔 发表于 2022-9-20 15:44:19

1

潜学C语言 发表于 2022-9-20 16:21:26

参考答案

铃痕 发表于 2022-9-20 16:27:39

a

小潘同学. 发表于 2022-9-20 17:13:35

鱼C有你更精彩^_^

Ryan小白 发表于 2022-9-20 17:39:05

0,因为计算机只能识别0和1。
1,机器语言
2,编译
3,是否可以直接执行
4,不可以
5,
6,
7,

[QWQ] 发表于 2022-9-20 17:58:39

0:计算机只能读懂机器码
1:机器码
2:编译
3:速率
4:是
5;转换成字节码打包带走
6:编译
7:亲们趁敌人吃饭进攻

晚间新闻报 发表于 2022-9-20 18:20:01

第一个程序课后测试题答案
页: 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 [1746] 1747 1748 1749 1750 1751 1752 1753 1754 1755
查看完整版本: S1E2:第一个程序 | 课后测试题及答案