111
1
1
本帖最后由 春野甜 于 2022-9-27 16:51 编辑
找了n次错成了
1
over
{:5_108:}
.
1
本帖最后由 0077 于 2022-9-27 23:09 编辑
1,只认识二进制
2,机器语言
3,编译
4,一般可以
5,有字节语言作中转
6,用特定竖点代表字母
7,亲们。。。。
https://i.niupic.com/images/2022/09/27/a5F6.png
HAHA
S1E2:第一个程序 | 课后测试题及答案 [修改]
查看参考答案
太难了
lhx@lhx-TUF-Gaming-FX505GE-FX86FE:~/FishC/sle2$ gcc count_lines.c -o count_lines
lhx@lhx-TUF-Gaming-FX505GE-FX86FE:~/FishC/sle2$ ./count_lines
计算中...
目前你总共写了 111 行代码!
{:5_103:}
123
学C就靠小甲鱼了!
查看参考答案
#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;
}