阿凡也叫果子 发表于 2019-9-3 15:36:48

1

ALIEN_NoT 发表于 2019-9-3 16:16:41

226

FOmaroon5 发表于 2019-9-3 16:25:11

22hang you cuowu ei

一定考上研71 发表于 2019-9-3 18:27:59

巴拉巴拉

杰妮儿睿 发表于 2019-9-3 19:36:16

1

Candy. 发表于 2019-9-3 19:40:51

0.它只认识二进制代码
1.机器码
2.编译
3.编译型语言可以直接cpu执行
解释型语言需要将源代码转化为中间代码再给解释器翻译给cpu
4.不行
5.不同的解释器可实现在不同操作系统下文件的执行
6.查表 特定符号对应一个字母
7.亲们趁敌人吃饭时发动进攻

苦咖啡QAAQ 发表于 2019-9-3 19:49:15

啊啊啊

china16888 发表于 2019-9-3 19:49:33

努力学习天天向上

xueshuai 发表于 2019-9-3 20:19:03

///

空城追dream 发表于 2019-9-3 21:49:06

你好,我刚学,我想知道课后作业程序从一开始就是这么编译的,如何到达count-lines

dongwenjie 发表于 2019-9-3 22:30:10

0.机器只能识别二进制0 1的代码
1.机器语言
2.编译
3.解释型语言需要解释器将语言进行翻译
4.能
5.使用解释器
6.使用符号组合来代表实际功能
7.QINMENCHENDiR

Mkai 发表于 2019-9-3 22:41:34

{:10_254:}

purplepp 发表于 2019-9-3 22:46:22


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

lou 发表于 2019-9-4 00:10:06

1

WITPEN白羽 发表于 2019-9-4 01:10:03

本帖最后由 WITPEN白羽 于 2019-9-4 01:11 编辑

$ gcc cs.c -o cs
cs.c: 在函数‘countLines’中:
cs.c:19: 错误:‘FTLF’未声明(在此函数内第一次使用)
cs.c:19: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
cs.c:19: 错误:所在的函数内也只报告一次。)
cs.c:19: 错误:‘fp’未声明(在此函数内第一次使用)
cs.c: 在函数‘findAllDirs’中:
cs.c:64: 错误:‘null’未声明(在此函数内第一次使用)
$


这事为什么啊,大佬 ,头文件我都写了啊没有少写

chenyaofei 发表于 2019-9-4 07:24:45

认真做题,积极学习

Jiawei.Lu 发表于 2019-9-4 10:28:13

test

再见少年 发表于 2019-9-4 11:37:08

加油,今天是第一天学习

小影子吖 发表于 2019-9-4 14:27:07

对答案

fdffdghe 发表于 2019-9-4 15:12:47

看一看答案
页: 377 378 379 380 381 382 383 384 385 386 [387] 388 389 390 391 392 393 394 395 396
查看完整版本: S1E2:第一个程序 | 课后测试题及答案