2777874281 发表于 2022-9-27 15:05:08

111

xsasa 发表于 2022-9-27 15:16:21

1

jungkookz 发表于 2022-9-27 15:35:57

1

春野甜 发表于 2022-9-27 16:45:11

本帖最后由 春野甜 于 2022-9-27 16:51 编辑

找了n次错成了

beanpound 发表于 2022-9-27 17:42:35

1

许辞先生 发表于 2022-9-27 20:08:14

over

EFFORT-x30 发表于 2022-9-27 21:29:55

{:5_108:}

璃月小冰箱 发表于 2022-9-27 22:13:55

.

Aris2020 发表于 2022-9-27 22:26:18

1

0077 发表于 2022-9-27 23:08:25

本帖最后由 0077 于 2022-9-27 23:09 编辑

1,只认识二进制
2,机器语言
3,编译
4,一般可以
5,有字节语言作中转
6,用特定竖点代表字母
7,亲们。。。。
https://i.niupic.com/images/2022/09/27/a5F6.png

guonn 发表于 2022-9-27 23:37:10

HAHA

zhoutianritian 发表于 2022-9-28 07:15:36

S1E2:第一个程序 | 课后测试题及答案 [修改]

小雨西 发表于 2022-9-28 09:12:19

查看参考答案

xmz1112 发表于 2022-9-28 11:18:20

太难了

努力打工吖 发表于 2022-9-28 12:28:52

lhx@lhx-TUF-Gaming-FX505GE-FX86FE:~/FishC/sle2$ gcc count_lines.c -o count_lines
lhx@lhx-TUF-Gaming-FX505GE-FX86FE:~/FishC/sle2$ ./count_lines
计算中...
目前你总共写了 111 行代码!

hello-fei 发表于 2022-9-28 12:40:13

{:5_103:}

xguolyx 发表于 2022-9-28 15:24:42

123

zxbkai 发表于 2022-9-28 16:51:43

学C就靠小甲鱼了!

sudAurora 发表于 2022-9-28 17:14:04

查看参考答案

cyk哦 发表于 2022-9-28 18:21:22


#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;
}
页: 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 [1756] 1757 1758 1759 1760 1761 1762 1763 1764 1765
查看完整版本: S1E2:第一个程序 | 课后测试题及答案