小甲鱼好厉害
chakai
1
#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,"/*.c"), &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)
{
strintf(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("目前你总共写了 %1d 行代码! \n\n", total);
system("pause");
return 0;
}
回复
6行代码
搞定
ok
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
学习学习
学习
对着答案
0.计算机只能读懂二进制
1.机器语言
2.编译
3.转换方式不同
4.能
5.翻译
6.编译
7.亲们趁敌人吃饭时发动进攻
我爱小甲鱼
答案呢
为什么照着写有bug还不知道怎么改{:5_104:}
qwq
比python难
0 只能识别机器码,需要转换语言
1 机器码
2 编译
3 前者效率高,是计算机底层的基础。后者能跨平台,方便
4 不能
5 像我们中英文互译,需要对表
6 懒得翻
666
有没有解出来的大神