L326523 发表于 2022-6-26 19:31:35

查看

cc阿鱼 发表于 2022-6-26 19:54:40


#include <>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <字符串>

#define 最大 256

长总计;

int countLines(const char *filename);
void findAllCodes(const char *path);
void findALLFiles(const char *path);

int countLines(const char *filename)
{
文件 *fp;
整型计数 = 0;
int temp;
      
if ((fp = fopen(filename, “r”)) == NULL)
      {
fprintf(stderr, “Can not open the file:%s\n”, filename);
返回 0;
      }
      
while ((temp = fgetc(fp)) != EOF)
      {
if (temp == '\n')
                {
计数++;
                }
      }
      
fclose(fp);
      
返回计数;
}

void findAllCodes(const char *path)
{
结构_finddata_t法;
长手柄;
char thePath, target;
      
strcpy(thePath, path);
if((handle = _findfirst(strcat(thePath, “/*.c”), &fa)) != -1L)
      {

                {
sprintf(target, “%s/%s”, path, fa.name);
总计 += 计数线(目标);
}while (_findnext(handle, &fa) == 0);
      }
   
_findclose(手柄);
}

void findALLDirs(const char *path)
{
结构_finddata_t法;
长手柄;
char thePath;
      
strcpy(thePath, path);
if((handle = _findfirst(strcat(thePath, “/*”), &fa)) == -1L)
      {
fprintf(stderr, “path %s is error!\n”,path);
返回;
      }
   

      {      
if (!strcmp(fa.name, “.”) || !strcmp(fa.name, “..”))
继续;
                  
if( fa.attrib == _A_SUBDIR)
                {      
sprintf(thePath, “%s/%s”, path, fa.name);
findAllCodes(thePath);
findALLDirs(thePath);
                }
}while (_findnext(handle, &fa) == 0);
   
_findclose(手柄);
}

int main()
{
字符路径 = “.”;
      
printf(“计算中...\n”);
      
findAllCodes(path);
findALLDirs(path);
      
printf(“目前你总共写了 %ld 行代码!\n\n”, total);
系统(“暂停”);
      
返回 0;
}

Wwitw 发表于 2022-6-26 21:53:38

1

Sugar920 发表于 2022-6-26 22:44:42

朕想知道

shanene 发表于 2022-6-26 23:08:10

这是一个回复

2383868303 发表于 2022-6-27 00:09:04

怎么有地方老错

Kaiyhamie 发表于 2022-6-27 00:53:45

{:5_90:}

梦落繁辞 发表于 2022-6-27 01:24:50

啦啦啦啦啦啦啦

尚语贤KIKO 发表于 2022-6-27 09:31:27

查看参考答案

studio月月鸟 发表于 2022-6-27 09:53:23

0.计算机只识别0和1
1.机器语言
2.编译
3.编译是直接直接给cpu,解释型语言是将代码给解释器然后,解释器翻译后给cpu
4.可以
5.
6.对应的字符有对应的意思,对照翻译
7.亲们趁敌人吃饭时发动进攻

1023069590 发表于 2022-6-27 11:03:11

试一试我的实力

亦然c 发表于 2022-6-27 11:19:41

加油

YUNIQLO 发表于 2022-6-27 11:39:46

hao

fxhhy 发表于 2022-6-27 11:41:25

lllllllllllllllllllllllllllllllllllllllllllllllllllll

总之我非常难 发表于 2022-6-27 14:16:33

我居然复制都是错的,我太垃圾了。。

CstudentXH 发表于 2022-6-27 15:51:13

1

wode443121 发表于 2022-6-27 15:54:11

2022年6月27日新人来报道,零基础自学。

safiaep 发表于 2022-6-27 16:33:44

太棒了

LikeGodGirl 发表于 2022-6-27 19:42:03

1

碰碰彭彭 发表于 2022-6-27 20:26:09


1
页: 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 [1655] 1656 1657 1658 1659 1660 1661 1662 1663 1664
查看完整版本: S1E2:第一个程序 | 课后测试题及答案