jixinzheng 发表于 2022-11-10 01:03:30

查看参考答案

蜡笔小兴久 发表于 2022-11-10 08:42:47

1

请吟于风 发表于 2022-11-10 12:30:18

that's so good

hjbhkjsjhd 发表于 2022-11-10 13:00:54

1

听起来就很李谱 发表于 2022-11-10 15:03:50


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

轨迹 发表于 2022-11-10 15:14:46

0.因为只认识1和0
1.机器语言
2.转码
3.不用二次转译
4.不能直接运行
5.因为需要转译所以会根据不同的平台转译不同的代码
6.机器语言0和1
7.亲们趁敌人吃饭时发动进攻

yykx1 发表于 2022-11-10 15:42:47

ok

KirkHinrich 发表于 2022-11-10 16:15:22

我爱鱼C

HolmeBiNG 发表于 2022-11-10 17:35:53

D:\C

HolmeBiNG 发表于 2022-11-10 17:36:31

HolmeBiNG 发表于 2022-11-10 17:35


诶,我发的这啥玩意儿,明明是想找作业的截图呜呜呜呜呜

2027066964 发表于 2022-11-10 17:42:49

羽落长风起12138 发表于 2022-11-10 20:31:51

答案

up16367 发表于 2022-11-10 21:01:53

0:因为计算机只认识二进制
1:机器语言
2:编译
3:先编译再执行,一边解释一边执行
4:能
5:使用不同平台对应的编译器来编译代码
6:编码

烟火诶不对 发表于 2022-11-10 21:39:45

查看参考答案

milkbobo 发表于 2022-11-10 21:57:58

查看参考答案

iteam 发表于 2022-11-10 23:24:25

       .

唯我独尊小脸猫 发表于 2022-11-10 23:26:33

第一天!

多情的明月 发表于 2022-11-10 23:30:58

要答案

狸追追 发表于 2022-11-11 09:29:51

查看答案

WSCJKDR 发表于 2022-11-11 09:47:58

我要看
页: 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 [1798] 1799 1800 1801 1802 1803 1804 1805 1806 1807
查看完整版本: S1E2:第一个程序 | 课后测试题及答案