{:10_266:}缓慢起步
#include < io.h>
#include < direct.h>
#include < stdio.h>
#include < stdlib.h>
#include < string.h>
#define MAX 256
长总计;
int countLines(const char *文件名);
无效 findAllCodes(const char *path);
void findALLFiles(常量字符 *路径);
int countLines(常量字符 *文件名)
{
文件 *fp;
int 计数 = 0;
int 温度;
if ((fp = fopen(filename, “r”)) == NULL)
{
fprintf(stderr, “无法打开文件:%s\n”, filename);
返回 0;
}
而 ((temp = fgetc(fp)) != EOF)
{
如果 (temp == '\n')
{
计数++;
}
}
关闭(fp);
返回计数;
}
无效 findAllCodes(常量字符 *路径)
{
结构_finddata_t fa;
长柄;
char thePath, target;
strcpy(路径,路径);
if((handle = _findfirst(strcat(thePath, “/*.c”), &fa)) != -1L)
{
做
{
sprintf(target, “%s/%s”, 路径, fa.name);
总计 += countLines(target);
}while (_findnext(句柄, &fa) == 0);
}
_findclose(手柄);
}
无效 findALLDirs(常量字符 *路径)
{
结构_finddata_t fa;
长柄;
char thePath[最大];
strcpy(路径,路径);
if((handle = _findfirst(strcat(thePath, “/*”), &fa)) == -1L)
{
fprintf(stderr, “路径 %s 是错误的!\n”,path);
返回;
}
做
{
if (!strcmp(fa.name, “.”) || !strcmp(fa.name, “..”))
继续;
if( fa.attrib == _A_SUBDIR)
{
sprintf(thePath, “%s/%s”, 路径, fa.name);
findAllCodes(路径);
findALLDirs(路径);
}
}while (_findnext(句柄, &fa) == 0);
_findclose(手柄);
}
int main()
{
char 路径 = “.”;
printf(“计算中...\n”);
findAllCodes(路径);
findALLDirs(路径);
printf(“目前你总共写了 %ld 行代码!\n\n”, total);
system(“暂停”);
返回 0;
}
好的
0. 它只认0和1
1. 机器语言
2.编译
3.
4.不能
0.为什么我们说计算机其实是“二傻子”?
——因为计算机的核心是CPU,它负责计算机大部分日常的计算功能,而CPU只能识别0和1,。
1.CPU 唯一认识的语言是什么语言?
——机器语言,也叫机器码,由纯数字组成
2.C 语言编写的源代码转换为汇编语言的过程叫什么?
——编译
3.编译型语言和解释型语言的本质区别是什么?
——对于CPU而言,编译型语言是将源代码先通过编译器编译为CPU认识的机器码(可执行文件),此后CPU随时都可以直接执行编译后的机器码;而解释型语言则不直接编译成机器码,而是将源码转成中间代码,然后发送给解释器,由解释器逐句翻译给CPU来执行。
4.在 Linux 系统上用 C 语言编译的可执行程序,是否能在 Windows 系统上执行?
——不能,因为不同的操作系统可执行文件的格式不完全相同,Windows上大部分可执行文件为PE格式,而Linux上大部分可执行文件为ELF格式。格式不同导致了不同的可执行文件无法跨平台直接使用。
5. 解释型编程语言是如何实现跨平台的?
——解释型编程语言为每个操作系统专门制定一个解释器作为中转,因此解释器只需提供一个统一的入口即可
6.莫斯密码的原理其实是什么?
——有相应的编码表进行查表,编码表里将英文字母和数字进行编码对应,便于查表。
7.视频中小甲鱼“故弄玄虚”的那段密文还原后是什么内容(中文)
亲们,趁敌人吃饭时,发起进攻
hello
0.他只能
1.二进制
2.转码
3.语言类型不同
4.可以
5.可执行代码是原码
6.二进制
1.c语言
3.编译型语言是将源代码一次性转换成二进制语言,转换成可执行程序解释型语言可以一边执行一边转换,不会生成可执行程序
4.可以
5.通过解释器,将相同的源代码解释成不同平台下的机器码
6.简单的字符对应然后翻译
test
查看参考答案
0.只认识0和1
1.机器语言
2.编译
3.是否需要运行是编译
4.能
5.编译成不同平台
6.编码和解码
7.00
加油
.
66666666666666
哈哈哈
#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;
}
看答案
跟着小甲鱼学C
计算中...
目前你一共写了119行代码!
我想知道