tkx- 发表于 2019-11-21 16:17:24

0.因为计算机听不懂我们的语言,只能通过转换为机器语言才能理解
1.机器语言
2.编译
3.过程不同,编译型语言效率高,解释型语言相对较低
4.不能
5.通过解释器翻译成机器语言再由cpu执行
6.代码,给字符定义
7.

杰克马 发表于 2019-11-21 19:48:51

看看答案

Lv12138 发表于 2019-11-21 21:07:07

厉害了

Flysheep 发表于 2019-11-21 21:21:18

为什么67行上的fa显示未定义标识符呢{:5_96:}

wskidd 发表于 2019-11-21 21:22:40

看看看

YYQZ 发表于 2019-11-21 21:23:57

5

13867027703 发表于 2019-11-21 22:02:44

1

hp卤肉面 发表于 2019-11-21 23:35:08

查看参考答案

黑金 发表于 2019-11-22 01:19:35

QINMEN秦门
CHENDI尘地
RENCHIFAN人吃饭
SHIFA事发
DONGJINGONG东进攻

21940i 发表于 2019-11-22 10:08:27

a

Czhifeng 发表于 2019-11-22 10:30:55

答案

pyy0419 发表于 2019-11-22 10:35:03

谢谢鱼老师{:5_91:}

1223345266 发表于 2019-11-22 11:06:37

tt

lyx123456 发表于 2019-11-22 13:33:36

102

lyx123456 发表于 2019-11-22 13:35:49

lyx123456 发表于 2019-11-22 13:33
102

哦,我复制的时候把第一行空了。。。。然后就变成102了

即刻方舟 发表于 2019-11-22 14:42:14


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

wsxxb 发表于 2019-11-22 16:28:56

向大佬学习

卑微小威 发表于 2019-11-22 16:42:08

好多错误。。。。。。。

雨如洁 发表于 2019-11-22 16:51:59

.

w754550476 发表于 2019-11-22 17:20:05

111
页: 458 459 460 461 462 463 464 465 466 467 [468] 469 470 471 472 473 474 475 476 477
查看完整版本: S1E2:第一个程序 | 课后测试题及答案