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, "/*"), &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;
}
11
来看答案啦
测试题:
0.答:因为计算机只能识别“0”和“1”这种机器语言;
1.答:机器语言;
2.答:编译;
3.答:编译型语言是运行前只需要编译一次就行了,解释型语言是每次运行前都需要进行编译;
4.答:可以
5.答:解释型语言不直接编译成机器码,而是将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU 来执行;
6.答:机器语言;
7.亲们趁敌人吃饭时发动进攻(qin men chen di ren chi fan shi fa dong jin gong)搜狗拼音打出来就是这样的了。。。。。。。。。。
等级太低上传不了图片,Ctrl+c复制源代码编译运行后显示写了211行代码,点击源代码最后面的“复制代码”编译运行后显示写了211行代码。
自己手动写上去的代码,在编译运行的时候出错了错误显示“undefined reference to 'strcov'”,搞了半天还是没有编译运行出来,我受不了了,第一次写代码就出问题了,还是一个字母一个字母对着抄下来的,唉。。。。。。
有哪位知道怎么解决的小哥看到了,希望能帮忙解决一下,感谢了!!!
第一次抄错了,搞了半天没有搞好,先平复下情绪,等会再抄一次试试
!
大佬辛苦了
因为CPU只能识别0和1
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;
}
谢谢谢谢
已做
昨天写的直接编译不出来,今天早上起来用了一个小时抄写和查错修改,最有编译运行了,显示写了313代码。。。。。。。 要继续努力了
0.
{:10_245:}
看看
本帖最后由 geen 于 2020-3-8 12:58 编辑
测试题:
0. 因为计算机只认识0和1;
1.机器语言;
2.编译;
3.说不出来;
4.不能直接运行,需要对源代码进行部分修改后才可以运行;
5.把不同平台的源代码解释成字符码,再用解释器解释成机器码;
6.使用具有映射关系的表对明文进行编码加密,只有拥有加密表的接收方才能解码成明文。
7.QINMEN
CHEND
IRENC
HIFP(AN)(把AN解码成了P)
SHIF
ADONG
JING(O)(漏了O)
NG
1
瞅一瞅