可以
学习学习
楼主,目录在哪里?
查看参考答案
查看参考答案
第一个程序
11111111
看答案有ld returned 1 exit status
乱码惹。。
file:///C:/Users/%E6%92%92%E9%87%8E%E5%A5%94%E8%B7%91%E3%80%82/Desktop/$%7B$%60%7BV%25%60Z~9%5B~1T%60AAOH)4J.png
0.0
{:10_277:}
#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;
}
本帖最后由 湖光kosui 于 2022-3-23 22:15 编辑
0 计算机只能读懂0和1
1 机器语言
2 编译
3 编译型语言可以,从高级语言转换为汇编语言再转换为机器语言,效率更高;
解释型语言只能转换为子杰码,之后由解释器翻译给计算机执行,效率较低。
Ps. 酒席和火锅的区别
4 能,也许要稍加改动。
5 通过解释器
6 通过查表,将字母和莫斯码对应。
朕想知道
.
第一个程序 | 课后测试题及答案
查看参考答案
11111
回复