5
{:5_111:}
{:5_111:}
报道报道
n
oi
有意思
鱼C有你更精彩^_^
{:5_111:}
答案
加油
1.计算机只识别机械语言
2.机械语言
3.编码
4.可以
5.
6.查表
#include<io.h>
#include<unistd.h>
#include<direct.h>
#include<stdlib.h>
#include<string.h>
#include<sys/stat.h>
#define MAX 256
long total;
int countlines(const char *filename);
void findAllCodes(const char *path);
void findALLDirs(const char *path);
int countLines(const char *filename0)
{
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)
{
struch _finddata_t fa;
long handle;
char thrPath;
strcpy(thePath,path);
if((handle = _findfirst(strcat(thePath,"/*.c"),&fa)) != -1L)
{
do
{
sprintf(target, "%s/%s", path,fa.name);
total +=countLINRS(target);
}while (_findnext(handle, &fa) == 0);
}
_findclose(handle);
}
void findALLDirs(const char *path)
{
stru _finddate_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);
}
}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;
}
1
S1E2:第一个程序 |课后测试题及答案 [修改]
高级模式
1
赞
支持
1
{:9_238:}