Chrisotos 发表于 2020-5-31 22:20:34

感谢!!!!!

雍和丶 发表于 2020-5-31 22:40:12

谢谢

chengbyzd 发表于 2020-5-31 22:59:07

u

吕泽森 发表于 2020-6-1 09:17:21


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

濛濛杂花垂 发表于 2020-6-1 10:20:53

感谢~

作风优良啊 发表于 2020-6-1 11:15:41

{:5_109:}

huitian147 发表于 2020-6-1 12:44:02

ASDASDASDASDAASDASDADS

zi-odeca 发表于 2020-6-1 13:54:22

程序截图

摘星计划 发表于 2020-6-1 14:04:32

感谢

443316732 发表于 2020-6-1 14:47:49

1

我如黑日 发表于 2020-6-1 15:19:56

0.因为计算机只能识别0和1的机器码
1.机器码
3.解码
4.不能
5.解释型语言不直接编译成机器码,而是将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU 来执行。
6.将英文和数字装换成点横发送出去,接受到之后在转换回英文和数字,实现远程传输信息
7.亲们趁敌人吃饭时发动进攻

我如黑日 发表于 2020-6-1 15:24:58

代码抄了运行显示这个 stray '\243' in program
我还以为是我抄错了,然后我直接复制代码运行,还是运行不了

DubNation 发表于 2020-6-1 15:32:52

来了来了,第一节课

fanguo 发表于 2020-6-1 16:47:52

{:5_103:}加油!~

无敌李毛 发表于 2020-6-1 16:49:41

1

DINGTWO_o 发表于 2020-6-1 16:51:44

ccc

马文越 发表于 2020-6-1 17:09:19

想知道小甲鱼最近在做啥?请访问-> ilovefishc.com

wtfitis 发表于 2020-6-1 18:12:20

123

摘星计划 发表于 2020-6-1 18:30:41

嘻嘻

fanguo 发表于 2020-6-1 18:35:41

{:10_250:}抄的运行不了 好多错
页: 714 715 716 717 718 719 720 721 722 723 [724] 725 726 727 728 729 730 731 732 733
查看完整版本: S1E2:第一个程序 | 课后测试题及答案