鱼C论坛

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

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

    [复制链接]
发表于 2022-12-8 23:57:00 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
问答题答案:
888


动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 00:07:22 | 显示全部楼层
问答题答案:
1


动动手答案:
1

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 00:33:38 | 显示全部楼层
问答题答案:
hello word

动动手答案:
WUFA

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

头像被屏蔽
发表于 2022-12-9 01:32:20 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 09:53:11 | 显示全部楼层
问答题答案:
1


动动手答案:

1
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 10:02:36 | 显示全部楼层
1问答题答案:



动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 10:53:20 | 显示全部楼层
1问答题答案:



动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 11:05:21 | 显示全部楼层
问答题答案:



动动手答案:
1

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 14:22:28 | 显示全部楼层
问答题答案:
鱼C有你更精彩^_^


动动手答案:
鱼C有你更精彩^_^

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 16:40:01 | 显示全部楼层
问答题答案:
0.计算机只认识0,1
1.机械语言
2.编译
3.前者为一个整体,后者即插即用
4.可以
5.
6.查表
7.



动动手答案:

#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
回复 支持 反对

使用道具 举报

发表于 2022-12-9 16:58:34 | 显示全部楼层
好多:



动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 18:17:43 | 显示全部楼层
问答题答案:0.只听得懂0和1。1.低级语言。2.编译。3.解释型需要编译器。4.能。5.通过解释器。6.助记符。7.亲们,趁敌人吃饭时进攻!



动动手答案:

  1. #include <io.h>
  2. #include <direct.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>

  6. #define MAX      256

  7. long total;

  8. int countLines(const char *filename);
  9. void findAllCodes(const char *path);
  10. void findALLFiles(const char *path);

  11. int countLines(const char *filename)
  12. {
  13.         FILE *fp;
  14.         int count = 0;
  15.         int temp;
  16.        
  17.     if((fp=fopen(filename,"r"))==NULL)
  18.         {
  19.                 fprintf(stderr,"Can not open the file: %s\n",filename);
  20.                 return 0;
  21.         }

  22. while((temp=fgetc(fp))!=EOF)
  23. {
  24.         if(temp=='\n')
  25.         {
  26.                 count++;
  27.         }
  28. }

  29.         fclose(fp);

  30.         return count;
  31. }

  32. void findAllCodes(const char *path)
  33. {
  34.         struct _finddata_t fa;
  35.         long handle;
  36.         char thePath[MAX],target[MAX];
  37.        
  38.         strcpy(thePath,path);
  39.         if((handle = _findfirst(strcat(thePath,"/*.c"),&fa)) != -1L)
  40.         {
  41.                 do
  42.                 {
  43.                         sprintf(target,"%s/%s",path,fa.name);
  44.                         total += countLines(target);       
  45.                 }while (_findnext(handle,&fa) == 0);
  46.         }
  47.        
  48.         _findclose(handle);
  49. }

  50. void findALLDirs(const char *path)
  51. {
  52.         struct _finddata_t fa;
  53.         long handle;
  54.         char thePath[MAX];
  55.        
  56.         strcpy(thePath,path);
  57.         if((handle =_findfirst(strcat(thePath,"/*"),&fa)) == -1L)
  58.         {
  59.                 fprintf(stderr,"The path %s is wrong!\n",path);
  60.                 return;
  61.         }
  62.        
  63.         do
  64.         {
  65.                 if(!strcmp(fa.name,".") || !strcmp(fa.name,".."))
  66.                 continue;
  67.                      
  68.                 if(fa.attrib == _A_SUBDIR)
  69.                 {
  70.                         sprintf(thePath,"%s/%s",path,fa.name);
  71.                         findAllCodes(thePath);
  72.                         findALLDirs(thePath);
  73.                 }     
  74.         }while(_findnext(handle,&fa) == 0);
  75.        
  76.         _findclose(handle);
  77. }

  78. int main()
  79. {
  80.         char path[MAX] = ".";
  81.        
  82.         printf("计算中...\n");
  83.        
  84.         findAllCodes(path);
  85.         findALLDirs(path);
  86.        
  87.         printf("目前你总共写了 %1d 行代码! \n\n",total);
  88.         system("pause");
  89.        
  90.         return 0;
  91. }
复制代码


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 19:49:55 | 显示全部楼层
问答题答案:



动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-9 21:22:40 | 显示全部楼层
问答题答案:



动动手答案:7


第一天作业.PNG
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-10 10:15:07 | 显示全部楼层
动动手答案:

0二进制
1机器语言
2编码
3有无解码器解码
4可以
5字节码和解码器
6查表
问答题答案:7亲们趁敌人吃饭时发动进攻
qinmenchendirenchifanshifadongjingong
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-10 14:24:05 | 显示全部楼层
666


小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-12-10 19:11:00 | 显示全部楼层
问答题答案:



动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-10 22:50:33 | 显示全部楼层
问答题答案:

鱼C有你更精彩^_^
动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-10 23:28:30 | 显示全部楼层
问答题答案:
鱼C有你更精彩^_^


动动手答案:


小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-12-11 01:06:58 | 显示全部楼层
问答题答案:



动动手答案:
................

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-12 00:45

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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