2023考研上岸
发表于 2023-4-23 21:12:27
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX256
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 = fget(fp)) !=EOF)
{
if(temp == '\n')
{
count++;
}
}
fclose(fp);
return count;
}
void find ALLCodes(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,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("目前你总共写了%1d 行代码! \n\n", total);
system("pause");
return 0;
}
北沈爱兔子
发表于 2023-4-23 21:30:51
^v^
tututu0223
发表于 2023-4-23 21:41:54
{:5_105:}
奥利奥10086
发表于 2023-4-23 23:06:15
1、计算机只能识别0和1 ,例如用C语言进行编程,编译器会先将C语言编译成汇编语言,再由汇编语言编译器编译成机器语言,最后由CPU读取,执行指令。
2、编译(C语言--汇编语言--机器语言)
3、编译型语言的源代码最终是被编译成机器代码(可执行文件.exe),CPU即可对其直接执行。解释型语言(JAVA,Python)不直接编译成机器码,而是将源代码转化为中间代码(JAVA--字节码--发送给解释器--由解释器逐句翻译给CPU来执行),好处在于可以实现跨平台的特性,缺点在于效率低(因为Java写出来的 是字节码,CPU读不懂,故每句都需要解释器进行解释)
4、可以,C语言具有效率高、灵活度高、可移植性高的特点,不同机器上C语言编译程序80%的代码是相通的。
5、
6、编译和解码的过程,一个萝卜一个坑
7、QINMEN CHEND IRENC HIFAN SHIF ADONG JINGO NG
Chenjiashen
发表于 2023-4-24 08:42:53
1
GGport
发表于 2023-4-24 09:42:56
1
thejin
发表于 2023-4-24 09:55:03
已达
snowbaIl
发表于 2023-4-24 14:54:08
666
老年人学语言
发表于 2023-4-24 15:07:20
查看
MX04
发表于 2023-4-24 21:03:52
1
Zb_s
发表于 2023-4-24 22:06:09
0.只认识0和1
1.机器语言
2.编译
3.执行方式不同
4.是
5.
6.
Maysea
发表于 2023-4-25 14:20:29
1
落雾飞花
发表于 2023-4-25 15:58:42
+1
carol1102
发表于 2023-4-25 17:04:22
1
苏左呢
发表于 2023-4-25 20:13:25
查看参考答案
LIUNOYIXIA
发表于 2023-4-25 22:50:18
:)
投稿zz
发表于 2023-4-26 08:39:30
呃呃额额好
winnerisme
发表于 2023-4-26 11:00:16
完成
朱东强
发表于 2023-4-26 19:59:58
11
D8ZYBTJ
发表于 2023-4-26 20:01:34
666666