kongxia 发表于 2021-10-11 23:00:53

lambertt1702 发表于 2021-10-11 23:47:36

C语言yyds

北咕鸡饭饭 发表于 2021-10-12 07:52:01

嗯?

JessiePan 发表于 2021-10-12 08:13:43

编译

云上. 发表于 2021-10-12 08:52:59


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

小赵同学快过来 发表于 2021-10-12 09:00:30

0

鱼儿要吃糖 发表于 2021-10-12 10:48:20

E:\photo\a1.png

拾荒独酌 发表于 2021-10-12 10:53:31

1

xcc3631869 发表于 2021-10-12 12:12:39

第一个程序

你好朋友 发表于 2021-10-12 12:25:17

1

dhgsadsg 发表于 2021-10-12 12:27:33

0

zmx0228 发表于 2021-10-12 14:54:13

0. 因为计算机只能够识别0和1.
1. 机器语言
2. 编译
3.编译型语言是由 高级语言 到 汇编语言 ,到机器语言 ,然后到 cpu执行
而解释型语言 是 高级语言 到 字节码 , 然后发送到解释器,再到 cpu执行
4. 可以, linux 和 windows 中都用了c语言
5.解释型语言 是 高级语言 到 字节码 , 然后发送到解释器,再到 cpu执行
6.查表
7.秦蒙趁敌人吃饭时发动进攻

初初初学者 发表于 2021-10-12 15:34:21

查看参考答案

L-MINGJ- 发表于 2021-10-12 15:41:37

答案

panmmmy 发表于 2021-10-12 15:50:10

查看参考答案

Gtyuuuuuu 发表于 2021-10-12 16:35:45

学习打卡

zyc19910824 发表于 2021-10-12 17:07:48

我感觉我学了堂假课,问题都不会{:10_254:}

1770308601 发表于 2021-10-12 17:19:59

1

莫夭阏 发表于 2021-10-12 18:00:19

【‘’】

fyq123 发表于 2021-10-12 18:38:10

123
页: 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 [1414] 1415 1416 1417 1418 1419 1420 1421 1422 1423
查看完整版本: S1E2:第一个程序 | 课后测试题及答案