1942261468 发表于 2021-11-9 15:26:26

查看参考答案

C~小白 发表于 2021-11-9 15:41:38

{:10_254:}

jtao 发表于 2021-11-9 15:44:23

666

被水淹死的宇 发表于 2021-11-9 16:23:47

感谢小甲鱼

用户wwl 发表于 2021-11-9 16:56:29

1

qbshadows 发表于 2021-11-9 17:56:15

#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<string.h>

#define MAX   256

long total;

int countlines(const char *filename);
void fineAIICodes(const char *path);
void findAIIFiles(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))!=EDF)
        {
                        if(temp=='\n')
                        {
                                cont++
                        }
        }
        fclose(fp);
       
        return count;
}

void findAIICodes(const char *path)
{
        stuct_finddata_t fa;
        long handle;
        char thePath, path);
        if((handle=_findfisrt(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)
        {
                frintf(stderr,"The path %s is wrong!\n",path);
               return;
       }
       
       do
       {
               if(!strcmp(fa.name,".")|| !strcmp(fa.name,".."))
                       continue;
              
                if(fa.atttrib==_A_SUBDIR)
                {
                        sprintf(thePath,"%s%s",path,fa_name);
                        findAIICodes(thePath);
                        findALLDirs(thePath);
               }        
       }while(_findnext(handle,&fa)==0);
       
       _findclose(handle);
}

int main()
{
        char path=".";
       
        printf("计算中...\n");
       
        findAIICodes(path);
        findALLDirs(path);
       
        printf("目前你总共写了%1d行代码!\n\n",total);
        system("pause");
       
        return 0;
}

280733712 发表于 2021-11-9 17:57:28

printf("目前你总共写了 %ld 行代码!\n\n", total);
      system("pause");

谢轩南 发表于 2021-11-9 19:15:37

1

其奈公何 发表于 2021-11-9 19:17:26

.

真是菜鸟 发表于 2021-11-9 20:16:31

计算中...
目前你总共写了 7 行代码!

ALin233 发表于 2021-11-9 20:33:01

111

zxy。 发表于 2021-11-9 20:56:01

第一个程序

wbm123 发表于 2021-11-9 21:28:28

德伟

zane.zhao 发表于 2021-11-9 21:30:13

haokbang

jaryseves 发表于 2021-11-9 21:34:27

44

坐星观井 发表于 2021-11-9 21:50:37

终于打完了

曦城月明 发表于 2021-11-9 21:55:50

测试题答案

Ymh1218 发表于 2021-11-9 22:21:50

1

a961119689 发表于 2021-11-9 22:58:49

a

牛顿看了会流泪 发表于 2021-11-9 23:15:10

6666666666
页: 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 [1453] 1454 1455 1456 1457 1458 1459 1460 1461 1462
查看完整版本: S1E2:第一个程序 | 课后测试题及答案