asky533 发表于 2022-8-31 22:09:56

测试题:
static/image/hrline/1.gif
第0题的答案:因为计算机只懂二进制比特位0和1,以及0和1组成的指令,其他啥也读不懂
第1题的答案:机器语言,就是0和1组成的指令
第2题的答案:叫做编译
第3题的答案:编译型语言是把代码翻译成汇编语言再翻译成机器语言,而解释型语言则是现将源码转换为中间代码,再将中间代码发送到解释器,最后由解释器翻译成机器语言
第4题的答案:大部分程序都可以在linux里面执行,但在linux系统里面C语言有更广阔的天地
第5题的答案:它不直接编译成机器码,而是将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU 来执行
第6题的答案:原理是像机器语言一样,摩斯密码可以以点横的方式组成密码,然后再通过特定的表破译

第7题的答案:汉语拼音:qin min chen di ren chi fan shi fa dong jin gong   汉语:亲民趁敌人吃饭时发动进攻?
static/image/hrline/1.gif


动动手:
static/image/hrline/1.gif
答案:
#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("计算中...\n");
      
      findAllCodes(path);
      findALLDirs(path);
      
      printf("目前你总共写了 %ld 行代码!\n\n", total);
      system("pause");
      
      return 0;
}
大概没错吧^_^

红尘HC 发表于 2022-8-31 22:54:05

d

yuzgy 发表于 2022-8-31 23:34:26

答案

tony666y 发表于 2022-9-1 01:27:58

?

qth 发表于 2022-9-1 09:10:19

1

安安555 发表于 2022-9-1 10:02:27

回复

富观 发表于 2022-9-1 10:02:45

Emmmm

刘乃银 发表于 2022-9-1 10:14:17

S1E2:第一个程序 |课后测试题及答案 [修改]
高级模式

念123 发表于 2022-9-1 11:09:48

1

绿叶酱 发表于 2022-9-1 11:12:22

{:5_109:}C:\Users\admin\Desktop\图片\甲鱼s1s2

卑鄙的外乡人QAQ 发表于 2022-9-1 13:29:52

11

143321 发表于 2022-9-1 13:59:42

0

我是呆瓜 发表于 2022-9-1 14:08:02

buzhidao

沉默之剑5105618 发表于 2022-9-1 15:10:12

666666

dijia 发表于 2022-9-1 15:55:24

测试题答案

yungui314 发表于 2022-9-1 16:07:33

看答案啦

Dracis 发表于 2022-9-1 16:14:44

{:5_97:}

shuolezaijian 发表于 2022-9-1 16:34:04

1

jifeifei 发表于 2022-9-1 17:19:39

甲鱼你好呀~

Sizheng 发表于 2022-9-1 17:46:24

打了快一个点才打完…打卡
页: 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 [1720] 1721 1722 1723 1724 1725 1726 1727 1728 1729
查看完整版本: S1E2:第一个程序 | 课后测试题及答案