黄乘号 发表于 2021-2-3 19:21:57

太棒了!希望自己能学会c。

zw23 发表于 2021-2-3 19:27:37

{:5_109:}

gowe 发表于 2021-2-3 20:03:49

ganxie

tpa 发表于 2021-2-3 20:28:50

0.计算机只懂得0和1
1. 机器码
2.编译
3.编译后语言是否可直接被CPU执行
4.可
5通过不同平台的解释器被各平台转化成可执行语言
6.对照表格资料翻译出信息,本身不可读取信息
7.亲们趁敌人吃饭时发动进攻

shenlangtao 发表于 2021-2-3 20:36:19

不懂

Jerome-092 发表于 2021-2-3 21:10:06

抄下来第一次没运行成功,检查了好几遍。最后成功了

Jerome-092 发表于 2021-2-3 21:11:22

为啥我是213行代码

Justin355a 发表于 2021-2-3 21:14:57

回复

xamund 发表于 2021-2-3 22:02:52

代码太长啦。容易出错,导致失去学习兴趣。

吕老头 发表于 2021-2-3 22:11:32

课后作业

臣卜臣卜木曹 发表于 2021-2-3 22:19:49

计算中...
目前你总共写了 121 行代码!

笔落惊风雨 发表于 2021-2-3 23:06:59

1.机器语言
2.编译
3.编译型语言是直接的编译成机器语言,解释型语言转化为字节码再发给解释器
4.可以,需要搭建虚拟机环境
5.
6.
7.qin men di ren chi fan shi fa dong jin gong

jinghongzhaoyin 发表于 2021-2-4 00:09:49

作业完成了

Huwei1999 发表于 2021-2-4 02:07:15

萌新到大佬 发表于 2021-2-4 10:18:36

查看参考答案

最聪明的蛋 发表于 2021-2-4 10:29:06

e

sddsm 发表于 2021-2-4 11:10:02


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

Melody65 发表于 2021-2-4 12:21:19

{:5_109:}

wuhua233 发表于 2021-2-4 13:03:46

1

lxklxk111 发表于 2021-2-4 13:22:52

1
页: 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 [1052] 1053 1054 1055 1056 1057 1058 1059 1060 1061
查看完整版本: S1E2:第一个程序 | 课后测试题及答案