何必在意i 发表于 2018-8-21 14:29:16

把空格算上了,不然应该是100行

沙耶加 发表于 2018-8-21 14:45:26

0.因为它傻
1.机器语言
2.编译
3.如何让CPU读懂源码
4.能
5.先将源码转化成中间语言,再将中间语言发送至解释器,由解释器进行翻译给CPU来执行
6.查表
7.亲们,趁敌人们侵犯时发动进攻

wankun123 发表于 2018-8-21 15:19:34

123

好好学习34 发表于 2018-8-21 16:29:28

1

梦想大牛 发表于 2018-8-21 16:54:09

回复就能看吗?

一枚小白 发表于 2018-8-21 17:07:03

终于打完了

jojookkk 发表于 2018-8-21 17:12:32

感觉进度还是快了点..

妖半岁 发表于 2018-8-21 18:58:07

看看

kwy 发表于 2018-8-22 11:21:52

照抄写错了....仍需多多练习....

Zozern 发表于 2018-8-22 12:42:24

目前菜鸡一只

lizijian 发表于 2018-8-22 14:28:24

谢谢诶谢谢谢爱的飒飒很大声

VOGHOST 发表于 2018-8-22 17:21:02

我要看答案

xingchen014 发表于 2018-8-22 18:42:56

#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 = ".";
       
        printf("calculate...\n");
       
        findAllCodes(path);
        findAllDirs(path);
       
        printf("you have write %ld rows codes! \n\n", total);
        system("pause");
       
        return 0;
}

aa887498 发表于 2018-8-22 19:42:51

图一时之快先看答案,哈哈

笔绘天空i 发表于 2018-8-22 20:48:52

真的学到了不少 感谢分享

AlexXu 发表于 2018-8-22 23:16:29

0.因为它很单纯
1.二进制码的机器语言
2.编译
3.一个只需要编译一次。另一个每次使用都需要用解释器解释
4.可以把
5.语言源码移植之后,只要目标机器上有相应语言的解释器,。就可以解释运行
6.原理是编译?
7.。。。。。。。不想查莫斯表

饥饿龙猫 发表于 2018-8-23 11:00:26

0.因为计算机只能识别机器码
1.机器码(机器语言)
2.编译
3.解释型语言不直接编译成机器码
4.可以
5.将源代码转化为中间代码,发送给翻译器,由翻译器逐句翻译给cpu来执行
6.编译
7.亲们趁敌人吃饭时发动进攻

Huasity 发表于 2018-8-23 14:38:10

做完等答案

信计兄弟 发表于 2018-8-23 16:14:53

x

放荡不羁的小李 发表于 2018-8-23 17:08:10

0. 因为计算机只认得二进制
1. 机器码
2. 编译
3. C语言效率更高,因为C语言编写的代码可以编译成汇编语言再编译成机器码,而解释性语言需要通过解释器翻译
4. 百分之八十的可能性可以
5. 通过不同平台的解释器
6. 就是通过声音的长短跟次数,用莫斯编码表进行编译或者解码
7. 亲们趁敌人吃饭时间发动进攻

页: 152 153 154 155 156 157 158 159 160 161 [162] 163 164 165 166 167 168 169 170 171
查看完整版本: S1E2:第一个程序 | 课后测试题及答案