太棒了!希望自己能学会c。
{:5_109:}
ganxie
0.计算机只懂得0和1
1. 机器码
2.编译
3.编译后语言是否可直接被CPU执行
4.可
5通过不同平台的解释器被各平台转化成可执行语言
6.对照表格资料翻译出信息,本身不可读取信息
7.亲们趁敌人吃饭时发动进攻
不懂
抄下来第一次没运行成功,检查了好几遍。最后成功了
为啥我是213行代码
回复
代码太长啦。容易出错,导致失去学习兴趣。
课后作业
计算中...
目前你总共写了 121 行代码!
1.机器语言
2.编译
3.编译型语言是直接的编译成机器语言,解释型语言转化为字节码再发给解释器
4.可以,需要搭建虚拟机环境
5.
6.
7.qin men di ren chi fan shi fa dong jin gong
作业完成了
。
查看参考答案
e
#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;
}
{:5_109:}
1
1