黑咖啡豆 发表于 2023-1-14 22:15:26

用macOS编译代码后为什么显示编写了0行代码?

想上岸的小张 发表于 2023-1-14 23:53:53

二进制
机器语言
编译
解释型语言要用翻译器
可以

查表

星际的远客 发表于 2023-1-15 09:10:48

0.计算机只能看懂机器语言,看不懂编程语言和汇编语言
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, 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;
}

Black_heart 发表于 2023-1-15 09:48:12

1

巨蟒与圣碑 发表于 2023-1-15 10:35:29

dddd

不如吃个肉夹馍 发表于 2023-1-15 12:00:55

{:5_109:}

zhangjinhan0928 发表于 2023-1-15 15:41:18

,

阿姐的小阿元~ 发表于 2023-1-15 16:45:23

666

Aszh 发表于 2023-1-15 18:19:24

做完了第一套题

点C入脑 发表于 2023-1-15 18:50:53

kankan

小mi糊 发表于 2023-1-15 22:00:38

0.数据在计算机中一01二进制序列存储

1.汇编语言

2.编译

3.对于编译型语,在执行之前先要经过编译器将源码转换成 汇编语言;解释型语言无需预先编译,而是由解释器逐行对源码进行解释,一边解释一边执行

4.不可以,Linux中可执行程序为.out

5.主要是通过**语言解释器**来实现跨平台

6.用特殊的符号代表具体的字母

7.亲们,趁敌人吃饭时,发动进攻。

Johnny_Seer 发表于 2023-1-16 09:38:24

1.计算机只能识别二进制
2.机器语言
3.编译
4.能
5.将源码转化为中间代码,然后发给解释器,再由解释器逐句翻译给CPU来执行。
6.原理是编译

wuhuhuhu0011 发表于 2023-1-16 10:40:20

查看参考答案

hlyx 发表于 2023-1-16 11:18:09

嘿,亲爱的鱼油,每天都要过得开心哦^_^

634987305 发表于 2023-1-16 11:54:47

0.只能机械地通过01判断内容
1.机器语言
2.翻译
3.
4.可以
5.通过解释器逐句翻译给cpu来执行
6.编码
7.

秃头打工媛 发表于 2023-1-16 14:05:13

让干啥就干啥

乡愁 发表于 2023-1-16 16:27:26

0.因为计算机只懂二进制0和1

1.机器语言

2.编译

3.编译型语言可以通过编译器编译为机器语言,解释型语言则是
   通过解释器将字节码翻译给CPU。前者效率相对更高,后者更低。

4.可以

5.通过解释器将字节码翻译给CPU

6.点横组合

7.亲们趁敌人吃饭时发动进攻

sy18822355639 发表于 2023-1-16 18:42:16

1

xhghy 发表于 2023-1-16 20:00:48

1

汐桐Yuzu 发表于 2023-1-16 21:06:14

0.计算机只认识0和1
1.机器语言
2.编译
3.是否直接编译成机器码
4.能
5.有解释器逐句翻译
6.查表
7.QFMENCHENDIRENCHIFANSHIFADLNGJINGONG
页: 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 [1833] 1834 1835 1836 1837 1838 1839 1840 1841 1842
查看完整版本: S1E2:第一个程序 | 课后测试题及答案