usian 发表于 2020-9-11 22:08:08

0

max燚龘 发表于 2020-9-11 22:49:17

打着好累

jhhmyjt 发表于 2020-9-11 23:06:48

{:5_95:}

ChinTaku 发表于 2020-9-11 23:50:56

头疼啊,检查三遍还是运行不了,索性直接看答案吧

haixian 发表于 2020-9-12 10:01:08

...

universe1 发表于 2020-9-12 10:43:29

nn

AWA` 发表于 2020-9-12 11:01:54

0 只懂得二进制
1 机器码
2 编译
3 编译型语言直接编译成机器语言 解释型语言转换成中间代码
4 不能
5 将源码转换成中间代码
6 查表
7 亲们趁敌人吃饭发起进攻

周周_93 发表于 2020-9-12 12:15:44

hh

Ryan学编程 发表于 2020-9-12 12:55:37

{:5_91:}

assiduous 发表于 2020-9-12 14:46:42


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

icecocotea 发表于 2020-9-12 14:58:57

第一节课打卡

yanmomomimomo 发表于 2020-9-12 15:16:03

{:7_132:}

百战天麦 发表于 2020-9-12 15:18:16

初学者

soybean 发表于 2020-9-12 15:25:35

来看答案了

a2409027456 发表于 2020-9-12 15:32:42

nrdte

2509710895 发表于 2020-9-12 15:52:16

xx

w5575040t 发表于 2020-9-12 16:04:08

查看答案

wangbaolin 发表于 2020-9-12 16:04:15

我一跑就出问题停止工作

tmacymc 发表于 2020-9-12 16:09:47

这大老板吊 发表于 2020-9-12 16:44:26

亲们趁敌人吃饭时发动进攻
页: 838 839 840 841 842 843 844 845 846 847 [848] 849 850 851 852 853 854 855 856 857
查看完整版本: S1E2:第一个程序 | 课后测试题及答案