haonan
本帖最后由 GFAFAS 于 2021-12-1 17:06 编辑
0.因为计算机只能听懂机器语言
1.机器语言
2.编译
3.使用翻译器和直接编译
4.不能
5.使用编译器
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;
}
2621373025 发表于 2021-12-2 11:16
#include
#include
#include
为什么不一样呢?
查看参考答案
1
0
有什么内容呢?
想看
做完了。。