2632518110 发表于 2020-12-7 17:09:58

66666

pxj795 发表于 2020-12-7 17:18:25

朕想知道

c青竹伞 发表于 2020-12-7 17:25:59

没错误,看下对不对

hope777 发表于 2020-12-7 17:31:03

根本不给过啊

lQWQll 发表于 2020-12-7 17:36:05

答案

BFQL 发表于 2020-12-7 18:14:45

查看参考答案

HANJUNK 发表于 2020-12-7 20:29:15

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

寒嵩or 发表于 2020-12-7 20:43:17

我来看看

佳奕来划水 发表于 2020-12-7 21:37:16

回复

微风拂过头皮 发表于 2020-12-7 21:58:06


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

pplong 发表于 2020-12-7 21:59:08

查看参考答案

展小昭 发表于 2020-12-7 22:54:01

感谢,查看答案咯

18475035740 发表于 2020-12-7 23:15:30

111

Lulu000406 发表于 2020-12-7 23:30:42

加油加油

我是真的牛逼 发表于 2020-12-8 09:15:33

第二节测试题打卡

橘猫特别胖 发表于 2020-12-8 10:37:18

0.只认识0和1
1.机器语言
2.编译
3.编译语言是把所有代码编译成汇编语言在转换为机器语言,解释型是通过解释器解释成编译语言在编译成汇编语言在转换为机器语言
4.可以
5.
6.根据特定规则把特定的字符转换特定的字符
7.

xxia 发表于 2020-12-8 10:59:54

哇啦啦

2694224794 发表于 2020-12-8 11:19:21

求答案

NiVe 发表于 2020-12-8 13:25:06

学习

834608957 发表于 2020-12-8 14:09:06

1
页: 964 965 966 967 968 969 970 971 972 973 [974] 975 976 977 978 979 980 981 982 983
查看完整版本: S1E2:第一个程序 | 课后测试题及答案