wwaanngg 发表于 2023-10-4 11:35:22

1

AlexMeccer 发表于 2023-10-4 13:13:46

1

Ych-Joshua 发表于 2023-10-4 15:12:27

看看

3138670952 发表于 2023-10-4 15:22:31

1

Walkingcao 发表于 2023-10-4 16:59:25

查看答案

坤凌猫 发表于 2023-10-5 00:43:57

1

希望有台苹 发表于 2023-10-5 09:54:35

第一个程序

Not_Omnipotent 发表于 2023-10-5 11:06:19

抄错了...

Duanhaocheng_c 发表于 2023-10-5 11:22:30

hh

tony绝不带水 发表于 2023-10-5 11:56:00

makabaka

泠泠七弦 发表于 2023-10-5 12:33:09

备菜 发表于 2023-10-5 15:13:06

0.只会0和1
1.机器语言
2.编译
3.有无翻译器
4.能
5.通过转换器
6.用罗斯密码表
7.

唯物主义道士 发表于 2023-10-5 16:40:36

查看参考答案

歌者ay、 发表于 2023-10-5 17:02:06

1

2237789981 发表于 2023-10-5 18:12:40

亲们趁敌人吃饭时发动进攻

蓝澈蓝澈 发表于 2023-10-5 19:32:31

看答案

career 发表于 2023-10-5 19:56:44

w

Tangyf 发表于 2023-10-5 20:42: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;
}

qweivun 发表于 2023-10-5 22:05:13

qweivun

a2878983900 发表于 2023-10-6 03:35:52

aa
页: 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 [1957] 1958 1959 1960 1961 1962 1963 1964 1965 1966
查看完整版本: S1E2:第一个程序 | 课后测试题及答案