xuluxupan 发表于 2024-11-1 17:35:42

答案

宋印捷 发表于 2024-11-1 19:42:06

0.无法直接与人类语言交流
1.机器语言
2.编译
3.需不需要借助中间介质,如解释器
4.可以
5.编译成字节码,然后发送给解释器,CPU再执行
6.指令
7.不知道
8.#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;
}

xiaoyaoz1231 发表于 2024-11-1 20:04:52

66666666666666

A卡11 发表于 2024-11-2 15:28:04

1

腻味#include 发表于 2024-11-2 18:56:24

#include <stdio.h>
int main()
{
        printf("Hello World!\n");
        return 0;
}

边缘的蒲公英 发表于 2024-11-2 22:57:47

测试题求答案

xiaocanyu 发表于 2024-11-3 12:45:52

1

kloikkkk 发表于 2024-11-3 13:08:32

本帖最后由 kloikkkk 于 2024-11-3 13:09 编辑

程序没抄错,为什么输出结果是3117行啊

Vinger 发表于 2024-11-3 18:46:44

11

AndyJHd 发表于 2024-11-3 20:58:19

ss

起名真的好难啊 发表于 2024-11-4 08:37:21

1

Sexypq 发表于 2024-11-4 11:29:36

回复

C-LearnerA 发表于 2024-11-4 21:23:50

Hello World!

梦想火炬 发表于 2024-11-4 23:09:35

2024年报个到

茉莉-小和 发表于 2024-11-5 10:43:45

{:5_105:}

原默zzz 发表于 2024-11-5 15:41:10

1

OvO. 发表于 2024-11-5 16:25:53

666

1140913853@QQ.C 发表于 2024-11-5 17:24:18

hi

HanKow 发表于 2024-11-5 21:23:49

1

shark888 发表于 2024-11-5 21:24:36

1
页: 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 [2076] 2077 2078 2079 2080 2081 2082 2083 2084 2085
查看完整版本: S1E2:第一个程序 | 课后测试题及答案