鱼C论坛

 找回密码
 立即注册
楼主: 小甲鱼

[课后作业] S1E2:第一个程序 | 课后测试题及答案

    [复制链接]
发表于 2021-1-31 17:42:44 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
0:二进制
1:机器语言
2:编译
3:cpu能否直接执行
4:可
5:将源代码转换为中间代码,发送给解释器,由解释器翻译给CPU执行
6:查表 编码和解码
7:qin men chen di ren chi fan shi fa dong jin gong
     亲们,趁敌人吃饭时发动进攻
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 17:50:06 | 显示全部楼层
学习学习,!!!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 18:21:25 | 显示全部楼层
第一天学习打卡
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 19:27:25 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-1-31 19:28:44 | 显示全部楼层
完成了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 19:49:54 | 显示全部楼层
109
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-1-31 19:59:19 | 显示全部楼层
回复
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-1-31 20:54:12 | 显示全部楼层
计算代码的数目吗
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 21:24:33 | 显示全部楼层
0.因为他需要人类通过编程语言与之沟通
1.机器语言
2.编译
3.第一个是通过将源代码编译成机器语言,是一个可执行文件,可以被CPU直接运行;第二个是将源代码转换为中间代码,例如java就是转换为字节码,然后通过解释器逐句翻译给CPU,CPU去运行
4.可以
5.因为解释型编程语言是将源代码转换为中间代码,不同的语言转换为不同的中间代码,不像编译型编程语言是直接转换为机器语言形成可执行文件,转换为中间代码通过解释器一句一句解释给CPU
6.将铭文编码成摩尔斯密码,或将密码解码成铭文
7.故弄玄虚
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 21:27:32 | 显示全部楼层

#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[MAX], target[MAX];
       
        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[MAX];
       
        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[MAX] =".";
       
        printf("计算中...\n");
       
        findALLCodes(path);
    findALLDirs(path);
   
    printf("目前你总共写了%ld行代码!\n\n,total");
    system("pause");
   
    return 0;
}  
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 21:32:19 | 显示全部楼层

#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[MAX], target[MAX];
        
        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[MAX];
        
        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[MAX] = ".";
        
        printf("计算中...\n");
        
        findAllCodes(path);
        findALLDirs(path);
        
        printf("目前你总共写了 %ld 行代码!\n\n", total);
        system("pause");
        
        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 23:07:25 | 显示全部楼层
看答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-31 23:57:24 | 显示全部楼层
0.因为计算机只能识别01这种机器语言
1.机器语言
2.编译
3过程不同,解释性编码不会直接进行转而是将源码转换成中间代码,发送给解释器,有解释器逐句解释给执行器执行
4.可以
5.通过解释器
6.将明文对着编码表翻译成点横组合
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-1 09:42:03 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-2-1 10:36:57 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-2-1 11:41:34 | 显示全部楼层
1.因为计算机只懂的二进制的“0”和“1”
2.CPU唯一认识的语言是机器语言
3.C语言编写的源代码转换为汇编语言的过程叫编译
4.解释型语言需要通过解释器
5.不行
6.通过修改或者删除就可以在其他平台上运行
7.查表
8.QINEN CHIN
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-1 12:00:50 | 显示全部楼层
太难了,一直错
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-1 12:08:29 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-2-1 12:40:11 | 显示全部楼层
截图有点大
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-1 12:57:55 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-23 20:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表