统计当前目录及所有子目录下,C 语言源文件的代码总行数,为0!
已完成第一课练习!
1
0. 计算机只能看懂2进制
1.机器语言
2.编译
3.编译型语言把源代码编译成机器语言,解释性语言将源代码转换成中间代码,再发送给解译器翻译给CPU执行
4.不可以吧。
5.
6.查表
初来乍到
1
{:5_102:}
0.因为计算机会有很多Bug出现
1.C语言
2.编译
3.解释型语言不直接编译成机器码,而是将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU 来执行。编译型语言直接编译成机器码
4.不可以
5.解释型语言不直接编译成机器码,而是将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU 来执行
6.查表
7.亲们趁敌人吃饭时发动进攻
{:5_102:}
感谢感谢
学习打卡
0.计算机只认识0、1
1.机器语言
2.编译
3.编译型:直接输出cpu可执行代码;解释型:不能直接输出cpu可执行代码
4.能
5.中间码,需用平台的解释器解释后方可让cpu执行
6.查表
7.哈哈哈
#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;
}
#include<io.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;
}
答案{:5_91:}
想要看答案
只懂二进制
忘了
后者给电脑时要多一步翻译
不能
忘了
忘了
有关吃饭
奥利给干了!
我要答案啊!!
查看答案