鱼C有你更精彩^_^
1
本帖最后由 godspeed512 于 2023-2-14 14:50 编辑
支持小甲鱼
第一次尝试代码……失败
1
ol
1
1
''
答案
学习
a
这是啥》》???
查看测试题答案
{:5_90:}
55
#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;
}
0.计算机cpu只懂得二进制的0和1
1.机器语言
2.编译
3.编译型语言是编译器将源代码编译成汇编语言,再通过汇编语言编译器编译成机器语言,CPU直接读取执行指令。
解释型语言是由编译器将源代码变成中间代码,中间代码交给解释器逐字翻译给cpu读取。
4.可以
5.解释型编程语言是将源代码变成中间代码,此时可以到解释器进行翻译给cpu
6.密码 解码的过程
7.亲们,趁敌人吃饭时候,发动进攻
{:5_91:}
结果显示乱码
..