Reachan 发表于 2021-2-17 15:50:37

感谢分享!!!

袁健大王 发表于 2021-2-17 15:55:11

谢谢老师

一个努力的人 发表于 2021-2-17 16:05:17

。。

么么哒答 发表于 2021-2-17 16:10:54

0.它只认汇编语言

kjyly 发表于 2021-2-17 16:12:53


#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-2-17 16:34:59

感谢感谢!!!

liudaocen 发表于 2021-2-17 17:22:37

t

Fury2333 发表于 2021-2-17 17:31:26

1

不讲伍德 发表于 2021-2-17 17:36:46

哈哈,加油

辉夜sing 发表于 2021-2-17 18:03:51

康康答案

再见C== 发表于 2021-2-17 18:27:21

答案

NoPuzzle 发表于 2021-2-17 18:42:57

11111

王旭光111 发表于 2021-2-17 18:59:12

嘻嘻

熊猫L046 发表于 2021-2-17 19:15:37

开始学习的第一天

梅朵夕颜 发表于 2021-2-17 20:00:50

0.因为01
1.机器语言
2.
3.编译成exe还是边解释边执行
4.能
5.插件?
6.对应

lisssj 发表于 2021-2-17 20:06:14

瞅一瞅

上课笑醒 发表于 2021-2-17 20:37:04

1,机器语言,二进制
2,编译
3,解释型语言效率低
4,不一定吧
5,
6,编码和解码
7,

malevolence 发表于 2021-2-17 23:00:51

答案

betcha 发表于 2021-2-17 23:13:29

{:10_257:}

九月华师 发表于 2021-2-18 01:49:57

努力学习钟
页: 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 [1071] 1072 1073 1074 1075 1076 1077 1078 1079 1080
查看完整版本: S1E2:第一个程序 | 课后测试题及答案