chyn77 发表于 2024-1-16 14:17:56

嘿,亲爱的鱼油,每天都要过得开心哦^_^

123456789012 发表于 2024-1-16 14:57:37

1

康康要努力 发表于 2024-1-16 19:25:23

1

梁骏豪 发表于 2024-1-16 20:40:54

1213

C语言滴初学者 发表于 2024-1-16 21:49:28

1

fake2002 发表于 2024-1-16 23:30:34

已做完,对答案

18078512032 发表于 2024-1-17 08:55:18

查看参考答案

努力学习发 发表于 2024-1-17 11:38:11

答案

热心溜得哗 发表于 2024-1-17 15:54:16

{:5_95:}

3267740763 发表于 2024-1-17 16:15:45

6666666666666666666

777sss 发表于 2024-1-17 16:25:02

{:5_102:}

@大好人 发表于 2024-1-17 16:50:06

0

Tim245 发表于 2024-1-17 19:36:10

只能识别固定内的语言,只会执行
机器语言
编码
区别不知道
不行
相通程度高
编译也解码

qq1674391280412 发表于 2024-1-17 20:32:51

查看参考答案

葱花必上岸 发表于 2024-1-17 21:49:32

看答案

蜗牛会飞诶! 发表于 2024-1-18 01:01:45



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

#define MAX         256

long total;

int countlines(const char *filenme);
void findAIICodes(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 findAIICodes(const char *path)
{
         struct _finddata_t fa;
         long handle;
         char thepath[MAX], target[MAX];

         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[MAX];

         strcpy(thepath, path);
         if((handle = _findfirst(strcat(thepath,"/*"), &fa)) == -1L)
         {
            fprintf(stderr, "The path %s is wrong!\n",path);
            return;
         }

         do
      {
            if (!strcasecmp(fa.name,".") || !strcmp(fa.name,"."))
             continue;

             if (fa.attrib == _A_SUBDIR)
             {
               sprintf(thepath,"%s%s",path, fa.name);
               findAIICodes(thepath);
               findALLDirs(thepath);
             }
      }while (_findnext(handle, &fa) == 0);

         _findclose(handle);   
   }

   int main()
   {
         char path[MAX] = ".";

         printf("计算中...\n");

         findAIICodes(path);
         findALLDirs(path);

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

         return 0;

   }



域中有四大 发表于 2024-1-18 11:56:36

答案

上岸兔 发表于 2024-1-18 12:31:19

1

耳机没电了 发表于 2024-1-18 14:53:48

S1E2:第一个程序 | 课后测试题及答案

牢大螺旋飞机 发表于 2024-1-18 15:41:36

1
页: 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 [1996] 1997 1998 1999 2000 2001 2002 2003 2004 2005
查看完整版本: S1E2:第一个程序 | 课后测试题及答案