岚山以北 发表于 2022-8-24 21:42:54

回复

donlfd 发表于 2022-8-24 22:44:00

{:5_106:}

心言 发表于 2022-8-25 11:51:48

{:9_237:}{:9_237:}

肉山带魔王 发表于 2022-8-25 12:16:01

0.因为计算机只是速度快,但是并不聪明,无法理解复杂的动作。
1.机器语言。也就是0和1组成的二进制语言。
2.编译。
3.不知道。
4.可以,应该Linx编译生成出来的C文件能通过Windos系统生成相应的编译文件。
5.不知道。
6.原理是查表,特定的横和点的搭配对应特定的字符。
7.查表很简单,但是我就不做了...

iistan 发表于 2022-8-25 16:50:26

1

iistan 发表于 2022-8-25 16:51:26


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

一y方通行 发表于 2022-8-25 17:04:29

看答案

木木学语言 发表于 2022-8-25 17:11:05

112

louisee 发表于 2022-8-25 21:44:14

1

盐汽水泡泡糖 发表于 2022-8-25 22:01:12

1

momorrr 发表于 2022-8-25 22:34:17

555

深山老麟 发表于 2022-8-25 22:48:37

搞完了

yjy2004 发表于 2022-8-25 23:02:06

chong

巧克利 发表于 2022-8-26 00:48:36

回复

后会有蕉 发表于 2022-8-26 01:48:25

答案

梦() 发表于 2022-8-26 11:13:31

7

liuhuiqin 发表于 2022-8-26 14:49:23

我来瞅瞅

Patronum_A 发表于 2022-8-26 14:54:22

牛啊

windhug 发表于 2022-8-26 15:01:48

23

liuhuiqin 发表于 2022-8-26 15:02:33

复制到clion里面报错呀
页: 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 [1715] 1716 1717 1718 1719 1720 1721 1722 1723 1724
查看完整版本: S1E2:第一个程序 | 课后测试题及答案