a1830667127 发表于 2022-5-22 18:24:48

出错了。。。

kkkkjl 发表于 2022-5-22 18:47:19

1

电脑纯小白 发表于 2022-5-22 19:54:00

来了兄弟们呢

hundandage 发表于 2022-5-22 20:05:59

1

18199673236 发表于 2022-5-22 22:15:34

小米绿豆汤 发表于 2022-5-23 09:12:47

11111111111111111111111111111111111

生生不息的鲸落 发表于 2022-5-23 20:04:33

测试题
0.只能识别0和1

1.机器语言

2.编译

3.是否为逐行编译执行

4.能

5.逐行编译执行

6.编码与解码

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

动动手
Input

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

Output
计算中…
Can not open the file: .dds.c
Can not open the file: .main.c
The path .bin is wrong!
The path .obj is wrong!
目前你总共写了 0 行代码!

请按任意键继续. . .

Zpeony 发表于 2022-5-23 20:16:56

Zzz

扶风之木 发表于 2022-5-23 23:02:39

1

微笑@掩盖忧伤 发表于 2022-5-23 23:31:19

鱼C有你更精彩^_^

枫枫枫枫 发表于 2022-5-24 07:41:37

0

夜半小夜曲 发表于 2022-5-24 10:02:37

yangyang5599 发表于 2022-5-24 10:55:19

很不错

扶风之木 发表于 2022-5-24 16:50:01

小甲鱼你好我用的vs编译器完全照抄的 但是不能调试是什么原因

bbse34 发表于 2022-5-24 18:23:48

答案

杜甫爱跳舞 发表于 2022-5-24 20:26:47

不知道为什么显示0行

wszjh333 发表于 2022-5-24 20:52:55

做好了,看看有没有错误

202A 发表于 2022-5-24 20:53:31

1

剪子布 发表于 2022-5-24 22:05:11

做出来了,走了很多弯路

爱学编程的小猪 发表于 2022-5-25 11:11:26

1
页: 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 [1638] 1639 1640 1641 1642 1643 1644 1645 1646 1647
查看完整版本: S1E2:第一个程序 | 课后测试题及答案