谢谢
868行{:10_256:}
1
谢谢小甲鱼
方法
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#define MAX 256
long total;
int countLines(const char *filename);
int isCode(const char *filename);
void findAllDirs(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;
}
int isCode(const char *filename)
{
int length;
length = strlen(filename);
if (!strcmp(filename + (length - 2), ".c"))
{
return 1;
}
else
{
return 0;
}
}
void findAllDirs(const char *path)
{
DIR *dp;
struct dirent *entry;
struct stat statbuf;
if ((dp = opendir(path)) == NULL)
{
fprintf(stderr, "The path %s is wrong!\n", path);
return;
}
chdir(path);
while ((entry = readdir(dp)) != NULL)
{
lstat(entry->d_name, &statbuf);
if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name))
continue;
if (S_ISDIR(statbuf.st_mode))
{
findAllDirs(entry->d_name);
}
else
{
if (isCode(entry->d_name))
{
total += countLines(entry->d_name);
}
}
}
chdir("..");
closedir(dp);
}
int main()
{
char path = ".";
printf("计算中...\n");
findAllDirs(path);
printf("目前你总共写了 %ld 行代码!\n\n", total);
return 0;
}
查看参考答案
101行代码 C:\Users\Administrator\Desktop
0,因为计算机没有思考能力,是按照人的命令执行
1,机器语言
2,编译
3,编译型语言是编译好执行,解释型语言是运行时编译
4,可以
5,解释型语言通过解释器实现跨平台
6,摩斯密码的原理是将不同的字母映射成对应的信号段,反之,拿到信号段,然后转换成字母,通过字母组合形成文本
7,亲们趁敌人吃饭时发动进攻
{:5_90:}
啊
看看答得对不
第次一没抄对,第二次测试完显示94行代码
love Fishc
0计算机只能识别0和1
1机器语言
2编译
3编译型语言可直接将代码转化为机器语言,而解释型语言要将代码转化为中间代码
4否
5解释型编程语言将代码转换层中间代码,再发送给解释器,由解释器转化为机器语言
6通过与摩斯密码表比对翻译
7亲们趁敌人吃饭时进攻
哦耶。好多不会,记下来了{:5_109:},要加油啊
谢谢分享!!!!
1
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
看看