打球都爱喝冰露 发表于 2023-9-5 10:32:16

1111111111111111

焊五遆 发表于 2023-9-5 12:52:12

查看答案

谢谢不谢 发表于 2023-9-5 13:04:02

1

B_Ender 发表于 2023-9-5 15:44:24

0 二进制
1 机器语言
2 编译
3 编译型一次性编译所有代码,解释型边编译边执行
4 不能
5 安装各自平台适用的解释器即可
6 不知道专有名词
7 亲们

CASHMONEYFREE 发表于 2023-9-5 15:48:01

{:5_106:}

Starolling 发表于 2023-9-5 16:57:50

感谢分享!

qq1513131958 发表于 2023-9-5 17:24:05

6666

fusetee123 发表于 2023-9-5 20:08:39

38781

old_dream 发表于 2023-9-5 20:14:57

加1

Kan0 发表于 2023-9-5 20:22:46

1

爱探险的哆啦 发表于 2023-9-5 20:23:00

#include <stdio.h>
#include <unistd.h>
#include < 啧啧啧>
#include < 字符串.h>
#include <stdlib.h>
#include <sys/stat.h>

#define 最大 256

长总计;

int countLines (const char *filename);
int isCode(const char *filename);
void findALLDirs(const char *path);

int countLines(const char *filename)
{
      文件 *fp;
      整数计数 = 0;
      整数温度:

                if ( (fp = fopen(文件名, "r")) == NULL)
                {
                        fprintf(stderr, "无法打开文件: %s\n", 文件名);
                        返回 0;
                }

      而 ( (temp = fgetc (fp) ) ! = EOF)
      {
                if (temp == '\n')
"test2.c" 108L, 1532C                                                                   13,1         顶端

欣睿 发表于 2023-9-5 20:44:01

1

Dahao-109 发表于 2023-9-5 21:13:27

kanakn

闲人某 发表于 2023-9-5 22:02:59

计算机只能读懂特定语言
机器语言
编译
编译型语言在源程序编译后即可在该平台运行,解释型语言在运行期间才编译
不能
主要是通过语言解释器来实现跨平台
由简单的短和长的脉冲及其间隔来表示字母和数字的相互转换
不知道

Lost_Mi_Yang 发表于 2023-9-6 07:47:38

本帖最后由 Lost_Mi_Yang 于 2023-9-6 08:13 编辑

感谢小甲鱼。

我觉得有两点需要提一下:

1、本次练习中windows系统的示例代码中声明了findALLFiles这个函数,但是后面没有定义它,对应的,后面的findALLDirs这个函数没有和其他函数一起声明,而是声明的同时进行了定义。我想这里应该是您一时疏忽吧,不过不影响代码运行结果,所以我就不去找茬区专门发帖了。

2、即使抄代码的过程中没有错误,最后运行结果也可能不对,因为学生相关的设置可能没有做好(唉)。我使用的是windows平台的VS Code,默认使用UTF-8编码,运行结果是乱码,改成GB 2312就可以输出正常的结果了。

不知道您有没有空刷到这里呢。

可一可再 发表于 2023-9-6 10:48:22

答案

是大大怪啊 发表于 2023-9-6 10:50:05

ddd

67505075 发表于 2023-9-6 10:52:28

不知道错哪

nice- 发表于 2023-9-6 11:12:32

好的

z俞z 发表于 2023-9-6 11:16:50


#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;
}
页: 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 [1939] 1940 1941 1942 1943 1944 1945 1946 1947 1948
查看完整版本: S1E2:第一个程序 | 课后测试题及答案