是向阳子啊 发表于 2021-7-14 10:57:00


EliaukStarrr 发表于 2021-7-14 12:10:50

1

blmhbkq 发表于 2021-7-14 12:20:16

111

小透明mmmmm 发表于 2021-7-14 12:45:03

666

curiosity_2020 发表于 2021-7-14 13:02:43

检查真的好难,有几处地方,自己写的话编译报错,复制过去就没事,可我还愣是看不出来哪里错了

Leo25 发表于 2021-7-14 13:09:37

这个好难啊

甲鱼粉嘿嘿 发表于 2021-7-14 14:00:24

distolu 发表于 2021-7-14 14:07:16

康康康康

Jerome2528 发表于 2021-7-14 14:18:58

daan

努力早睡的小柒 发表于 2021-7-14 14:53:10

因为计算机是由人类发出指令后执行
机器语言
编译
编译型语言编译出后可以直接被CPU执行
解释型语言不直接编译成机器码,而是把源代码转化为中间代码,然后发送给解释器,由解释器翻译给CPU来执行
可以
解释型语言是通过解释器再到CPU被执行的
编码和编译
亲们趁敌人吃饭时发动进攻

Leo25 发表于 2021-7-14 15:49:45

甲鱼,我输入./count_lines.c 它显示权限不够,我登录了root也显示权限不够,这需要怎么弄呢?

heng333 发表于 2021-7-14 15:56:21


#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;
}

rain孤雨 发表于 2021-7-14 16:09:10

只认识0 1
机器码
编译
是否可以一次性执行
不能
编译成字节码然后由解释器翻译
亲们沉底人吃饭私发东京狗

努力早睡的小柒 发表于 2021-7-14 16:19:37

计算中……
Can not open the file: .7.14-01.c
Can not open the file: .7.14-02(100).c
目前你总共写了0行代码。

请按任意键继续. . .
请问一下为什么我输入之后会出现这种情况呀

扶风不知雨 发表于 2021-7-14 16:41:26

1

KobeBooker 发表于 2021-7-14 16:44:49

A

虎哥 发表于 2021-7-14 16:54:22

1

学编程的小小怪 发表于 2021-7-14 17:03:06

答案

姬丝汀独步 发表于 2021-7-14 17:10:39

报道

chumakejd 发表于 2021-7-14 17:14:04

查看参考答案
页: 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 [1255] 1256 1257 1258 1259 1260 1261 1262 1263 1264
查看完整版本: S1E2:第一个程序 | 课后测试题及答案