Froggen 发表于 2021-9-9 17:54:20

.

ammonlevele 发表于 2021-9-9 18:06:34

我要看下答案!!!

shuaishuai5219 发表于 2021-9-9 19:22:08

查看参考答案

小罗大聪明 发表于 2021-9-9 19:51:44

目前你总共写了7行代码!

fanweishuai 发表于 2021-9-9 19:58:46

测试题答案

tsdatsa 发表于 2021-9-9 20:10:30

xxxxx

杜昊学 发表于 2021-9-9 20:17:52

wow

2122845838 发表于 2021-9-9 20:41:27

huifu

王子金 发表于 2021-9-9 21:01:24

加油

Delphine1127 发表于 2021-9-9 21:17:55

答案是什么啊

爱国愚 发表于 2021-9-9 21:24:35

机器语言

Masonary 发表于 2021-9-9 21:39:43

检查答案

Mr李狗 发表于 2021-9-9 22:22:45

来了

小陈快学习 发表于 2021-9-9 22:34:40

666

aslyyds 发表于 2021-9-9 22:46:20

#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;
          intcount = 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(stract(thePath,"/*.c"), &fa)) != -1L
           {
                    do
                    {
                                  sprintf(target)
                                }
          
                }

      _findclose(handle)
}

void findALLDirs(const char *path)
{
          strust _finddata_t fa;
               long handle;
               char thePath;
                  
                strcpy(theePath,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;
}

番茄啊 发表于 2021-9-9 23:35:41


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

CPXjazz 发表于 2021-9-9 23:40:49

0.计算机只会识别二进制

1.C语言

2.编译

3.

4.可以

5.

6.编码,解码

7.QINMEN CHENDIRENCHIFANSHIFADONG

VI7EW 发表于 2021-9-10 07:36:55

真想知道

kunkun3110 发表于 2021-9-10 08:00:10

13139213936 发表于 2021-9-10 08:49:21

查看参考答案
页: 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 [1359] 1360 1361 1362 1363 1364 1365 1366 1367 1368
查看完整版本: S1E2:第一个程序 | 课后测试题及答案