哈哈哈哈哈哈涵 发表于 2021-4-15 14:24:39

1

tonystark3536 发表于 2021-4-15 15:03:28

kankan

siyi1998 发表于 2021-4-15 16:17:01

{:10_254:}

Wyc.c 发表于 2021-4-15 17:02:01

计算机只认识汇编语言
编译
字节码

怡斋之主 发表于 2021-4-15 17:38:06

1

yicon 发表于 2021-4-15 18:18:38

1

zwfweifeng 发表于 2021-4-15 18:20:58

1

13217346298 发表于 2021-4-15 18:53:51

答完了

tooyou 发表于 2021-4-15 19:50:27


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

1552457022 发表于 2021-4-15 20:08:39

{:5_90:}

小明kk 发表于 2021-4-15 20:12:25

PAUL3 发表于 2021-4-15 20:46:44

0.0

wuhang 发表于 2021-4-15 21:12:35

看答案

kokers10 发表于 2021-4-15 21:54:46

1

wwxjp 发表于 2021-4-15 22:07:00

二进制,机器语言,编译,解释型有一个解释过程效率低有字节码;否;不同平台的不同解释器可以解释向东的代码;编码;代码

ZK要认真学c 发表于 2021-4-15 22:08:06

第四天

山河易逝 发表于 2021-4-15 23:25:14

1

snowing_ 发表于 2021-4-15 23:33:59

这。。我敲出来958行代码,但是咋上传图片啊○| ̄|_,为什么我只有一个让输入图片地址,问号脸,难道是我浏览器不行吗

snowing_ 发表于 2021-4-15 23:54:16

snowing_ 发表于 2021-4-15 23:33
这。。我敲出来958行代码,但是咋上传图片啊○| ̄|_,为什么我只有一个让输入图片地址,问号脸,难道是我浏 ...

好耶,我还有敲错的地方,裂开

瞄了个咪哟 发表于 2021-4-16 01:09:23

啊?怎么看?
页: 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 [1159] 1160 1161 1162 1163 1164 1165 1166 1167 1168
查看完整版本: S1E2:第一个程序 | 课后测试题及答案