lveGakki 发表于 2020-6-3 16:19:55

+1

15545499869 发表于 2020-6-3 17:00:12

我想先试试怎么使用,所以发个回复

依风入海 发表于 2020-6-3 17:01:06

11111

木鱼魔王 发表于 2020-6-3 17:31:12

谢谢

xcpxcp 发表于 2020-6-3 18:58:14

10kb太小了

aa1122 发表于 2020-6-3 19:25:30

{:10_266:}{:10_266:}

THENINE 发表于 2020-6-3 20:42:52


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

haogea 发表于 2020-6-3 21:16:09

看一下答案

m8458246 发表于 2020-6-3 21:45:15

0、计算机只能识别二进制
1、机器语言
2、编译
3、编译型语言更接近底层硬件,解释型语言需要解释器才能运行
4、Linux下编译的不能直接在windows上运行
5、在每个平台上安装解释器,解释器会帮助解释代码
6、用长波与短波组成对照表,对照解释含义
7、亲们,趁敌人吃饭发动进攻

charlcoin 发表于 2020-6-3 23:15:35

学习打卡,感谢小甲鱼

噶角度 发表于 2020-6-3 23:52:40

回复

琢磨入君 发表于 2020-6-4 01:00:08

落后码农的未来 发表于 2020-6-4 02:37:58

看完咯,来拿题

xzzd1234 发表于 2020-6-4 09:58:34

这个是怎么回事

阮禹霖 发表于 2020-6-4 10:52:07

Daan

77808504 发表于 2020-6-4 10:52:08

感谢

north-find 发表于 2020-6-4 12:45:09

00

zhifei888 发表于 2020-6-4 13:02:20

非常感谢

阿艾AI 发表于 2020-6-4 13:55:48

厉害

yul_0 发表于 2020-6-4 13:55:51

答案
页: 717 718 719 720 721 722 723 724 725 726 [727] 728 729 730 731 732 733 734 735 736
查看完整版本: S1E2:第一个程序 | 课后测试题及答案