emmmmmem 发表于 2020-5-17 14:09:29

emm

wobic 发表于 2020-5-17 14:10:54

打卡

ifeelanxious 发表于 2020-5-17 15:05:08

101

我牙尖爪利qwq 发表于 2020-5-17 15:24:11

0、计算机只能读懂0和1
1、机器语言
2、编译
3、编译型语言通过编译后给cpu执行

HelloBob 发表于 2020-5-17 15:49:17

RE: S1E2:第一个程序 | 课后测试题及答案 [修改]

wobic 发表于 2020-5-17 16:08:17

找错找的脑袋都蒙了,报错不一定在它指定的那行,有时候在上面几行。

artyer 发表于 2020-5-17 16:18:50


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

小废物阿月 发表于 2020-5-17 18:58:26

机器语言

WA730730 发表于 2020-5-17 19:19:39

打卡

纸飞机的梦 发表于 2020-5-17 21:45:06

感谢小甲鱼

爱出手的棒槌 发表于 2020-5-17 22:40:20

{:5_105:}

zhouwz 发表于 2020-5-17 22:41:47

C:\Users\28573\Desktop

傻逼二代 发表于 2020-5-17 23:19:10

答案

oyhp 发表于 2020-5-18 08:41:23

.

gukai1997 发表于 2020-5-18 09:52:16

看看看看看看看

麦旋风o 发表于 2020-5-18 10:34:43

0

西顾 发表于 2020-5-18 12:07:01

kkkkkkkkk答案

Ellaevak 发表于 2020-5-18 12:24:53

运行了8行代码

WH123123 发表于 2020-5-18 14:53:43

新学员报道!

黎子 发表于 2020-5-18 15:30:58

查看答案
页: 697 698 699 700 701 702 703 704 705 706 [707] 708 709 710 711 712 713 714 715 716
查看完整版本: S1E2:第一个程序 | 课后测试题及答案