随遇而安啊 发表于 2021-7-16 11:10:03

想知道

风吟叶寒 发表于 2021-7-16 11:25:19

1

福尔摩斯的徒弟 发表于 2021-7-16 11:25:45

0 只能读取0和1
1 机器语言
2 编译
3 编译出的机器语言可直接被CPU执行,而解释型语言需要通过解释器解释后才能被CPU执行
4 能,C语言可移植性高
5 解释型语言将源代码转化为中间码,再通过解释器翻译给CPU执行,故具有跨平台性
6 编码和解码
7 亲们趁敌人吃饭时发起进攻

2179354658 发表于 2021-7-16 11:43:20

查看答案

雷总粉丝后援 发表于 2021-7-16 12:28:45

1

二十一! 发表于 2021-7-16 13:26:51

查看参考答案

sdcc 发表于 2021-7-16 13:50:05

{:5_102:}

qq312lm 发表于 2021-7-16 14:16:31

来了来了,做好题立马来看答案了

猩猩哥 发表于 2021-7-16 14:40:03

查看参考答案

浅酌清酒 发表于 2021-7-16 14:57:50

查看参考答案

1936638069 发表于 2021-7-16 15:02:31

1

1936638069 发表于 2021-7-16 15:03:16

1

1015712002 发表于 2021-7-16 15:03:47

d

小菜鸟661 发表于 2021-7-16 15:10:06

daan

Eker 发表于 2021-7-16 15:22:20

查看参考答案

要一直学下去啊 发表于 2021-7-16 15:37:53

#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>

#define MAX 256

long total;

int countlines(const char *filename);
int isCode(const char *filename);
void findAllDirs(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;
}

int isCode(const char *filename)
{
        int length;
       
        length = strlen(filename);
       
        if (!strcmp(filename + (length - 2), ".c"))
        {
                return 0;
        }
        else
        {
                return 0;
        }
}

void findAllDirs(const char *path)
{
        DIR *dp;
        struct dirent *entry;
        struct stat statbuf;
       
        if ((dp = opendir(path)) == NULL)
        {
                fprintf(stderr, "The path %s is wrong!\n", path);
                return;
        }
       
        chdir(path);
        while ((entry = readdir(dp)) !=NULL)
        {
                (entry->d_name, &statbuf);
               
                if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name))
                        continue;
                        
                        if (S_ISDIR(statbuf.st_mode))
                        {
                                findAllDirs(entry->d_name);
                                }
                                else
                                {
                                        if (isCode(entry->d_name))
                                        {
                                                total += countLines(entry->d_name);
                                        }
                                }
        }
       
        chdir("..");
        closedir(dp);
}

int main()
{
        char path = ".";
       
        printf("计算中...\n");
       
        findAllDirs(path);
       
        printf("目前你总该写了 %ld 行代码!\n\n",total);
       
        return 0;
}

王霈然 发表于 2021-7-16 15:55:39

好难啊

ssuperdragon 发表于 2021-7-16 16:17:04

修改

squirrel24 发表于 2021-7-16 16:27:20

打完代码人都没了{:10_266:}

征服c 发表于 2021-7-16 16:54:32

修改
页: 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 [1259] 1260 1261 1262 1263 1264 1265 1266 1267 1268
查看完整版本: S1E2:第一个程序 | 课后测试题及答案