鱼C论坛

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

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

    [复制链接]
发表于 2021-10-18 17:39:53 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
初来乍到
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 17:52:33 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

使用道具 举报

发表于 2021-10-18 20:05:56 From FishC Mobile | 显示全部楼层
计算机语言
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 20:15:35 | 显示全部楼层
查看
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 20:18:53 | 显示全部楼层
14
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 20:40:40 | 显示全部楼层
0.计算机只能执行正确的命令
1.CPU唯一认识的是机器语言,也就是由0和1组成的语言
2.C语言编写的源代码转换为汇编语言的过程称为编译
3.编译型语言是由编译器将高级语言转换汇编语言,然后再由汇编语言编译器转换为机器语言,从而让CPU能够读懂并执行;解释型语言是由将源代码转化为中间码,然后将中间码发送给编译器,由编译器逐句翻译给CPU执行,也因此编译型语言效率更高。
4.可以。
5.将解释型编程语言转化为中间码,然后将中间码发送给编译器,由编译器逐步翻译给CPU执行。
6.查表,每个字符都和一个码相对应。
7.Q I N M E N
C H E N D
I R E N C
H I F A N
S H I F
A D O N G
J I N G O N G
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 21:44:04 | 显示全部楼层
111
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 21:50:29 | 显示全部楼层
111
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 22:23:38 | 显示全部楼层
答案
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 22:32:40 | 显示全部楼层
#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 findALLFilse(const char *path);

int countLines(const char *filename)
{
        FILE *fo;
        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(temo == '\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(syrcat(thePath,"/*.c"),&fa))!= -1L)
        {
                do
                {
                        sprintf(target,"%s/%s",path,fa.name);
                        titak += 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-10-18 22:36:47 | 显示全部楼层
0、听不懂人话
1、由0和1组成的机器语言
2、编译
3、编译型语言是将所有代码编译过后生成可执行文件,可执行文件是机器能直接读懂的。而解释型语言需要中间解释器逐句将字节码翻译给机器执行
4、可以
5、需要在不同的平台提供不同的解释器
6、通过不同的·和一组合来表示不同的字母、数字、符号
7、亲们,趁敌人吃饭时发动进攻
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 22:44:59 | 显示全部楼层
#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 findALLFilse(const char *path);

int countLines(const char *filename)
{
        FILE *fo;
        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(temo == '\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(syrcat(thePath,"/*.c"),&fa))!= -1L)
        {
                do
                {
                        sprintf(target,"%s/%s",path,fa.name);
                        titak += 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;
}
本人电脑小白,用dev--C++打出来不行,直接复制你的代码显示出来的是0行,是不能用dev--C++打这一串代码吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 22:55:01 | 显示全部楼层
HHH
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 23:03:25 | 显示全部楼层
答案
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 23:42:58 | 显示全部楼层
查看参考答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 23:43:37 | 显示全部楼层
查看参考答案
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-19 00:24:30 | 显示全部楼层
hellow word
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-19 08:02:35 From FishC Mobile | 显示全部楼层
0.他只认识机器语言.听不懂人话
1.机器语言
2.编译
3.作用不同
4.6能
5.国际规定
6.写代码,找字母
7.具有中国特色
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-19 08:03:52 From FishC Mobile | 显示全部楼层
S1E2;第一个程序
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-21 04:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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