电控渣 发表于 2021-12-1 16:59:30

haonan

GFAFAS 发表于 2021-12-1 17:03:05

本帖最后由 GFAFAS 于 2021-12-1 17:06 编辑

0.因为计算机只能听懂机器语言
1.机器语言
2.编译
3.使用翻译器和直接编译
4.不能
5.使用编译器
6.对表
7.亲们趁敌人吃饭时发动进攻

邹大哥 发表于 2021-12-1 18:59:31

查看答案

删除、过去 发表于 2021-12-1 19:28:23

出错了

忘语silence 发表于 2021-12-1 20:49:15

查看参考答案

18821813154 发表于 2021-12-1 21:56:28

小甲鱼~

yaya2021 发表于 2021-12-1 22:24:13

感谢楼主

三句 发表于 2021-12-1 22:37:29

加油

18821813154 发表于 2021-12-1 23:07:22

手机端的编译器和在线版是不是会报错

小兔子一号 发表于 2021-12-2 00:08:19

答案

2530445512 发表于 2021-12-2 07:34:00

加油!

shirali 发表于 2021-12-2 10:24:56

代码已敲完,比对答案

2621373025 发表于 2021-12-2 11:16:43

#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;
}

2621373025 发表于 2021-12-2 11:17:25

2621373025 发表于 2021-12-2 11:16
#include
#include
#include


为什么不一样呢?

Yojirooo 发表于 2021-12-2 14:20:35

查看参考答案

2779887879 发表于 2021-12-2 16:28:11

1

2954252484 发表于 2021-12-2 16:30:07

0

李青灼 发表于 2021-12-2 18:25:28

有什么内容呢?

九如彡 发表于 2021-12-2 19:49:17

想看

1016686656 发表于 2021-12-2 19:58:10

做完了。。
页: 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 [1477] 1478 1479 1480 1481 1482 1483 1484 1485 1486
查看完整版本: S1E2:第一个程序 | 课后测试题及答案