cbcg 发表于 2023-2-14 10:15:59

鱼C有你更精彩^_^

yaoyuzhou 发表于 2023-2-14 13:45:28

1

godspeed512 发表于 2023-2-14 14:39:07

本帖最后由 godspeed512 于 2023-2-14 14:50 编辑

支持小甲鱼

第一次尝试代码……失败

aoteman12330 发表于 2023-2-14 15:10:13

1

wresst 发表于 2023-2-14 16:50:39

ol

TonyPony 发表于 2023-2-14 20:30:03

1

爱学习的浩浩 发表于 2023-2-14 21:01:50

1

醉里挑灯看剑、 发表于 2023-2-14 21:30:35

''

chenjinbiao 发表于 2023-2-14 22:40:55

答案

tiger729 发表于 2023-2-15 11:50:52

学习

学ccc的林 发表于 2023-2-15 12:08:05

a

Mr.luyouxiu 发表于 2023-2-15 12:21:49

这是啥》》???

魔大头 发表于 2023-2-15 15:33:24

查看测试题答案

江流懿 发表于 2023-2-15 17:37:01

{:5_90:}

xdsd 发表于 2023-2-15 18:14:07

55

元贝老师 发表于 2023-2-15 18:23:42

#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>

#define MAX 256

long total;

int countLines(const char *filename);
int isCode(const char *filename);
void findAllDirs(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;
}

int isCode(const char *filename)
{
      int length;

      length = strlen(filename);
      
      if (!strcmp(filename + (length - 2), ".c"))
      {
                return 1;
      }
      else
      {
                return 0;
      }
}

void findAllDirs(const char *path)
{
      DIR *dp;
      struct dirent *entry;
      struct stat statbuf;

      if ((dp = opendir(path)) == NULL)
      {
                fprintf(stderr, "The path %s is wrong!\n", path);
                return;
      }

      chdir(path);
      while ((entry = readdir(dp)) != NULL)
      {
                lstat(entry->d_name, &statbuf);

                if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name))
                        continue;

                if (S_ISDIR(statbuf.st_mode))
                {
                        findAllDirs(entry->d_name);
                }
                else
                {
                        if (isCode(entry->d_name))
                        {
                              total += countLines(entry->d_name);
                        }
                }
      }

      chdir("..");
      closedir(dp);
}

int main()
{
      char path = ".";

      printf("计算中...\n");

      findAllDirs(path);

      printf("目前你总共写了 %ld 行代码!\n\n", total);

      return 0;
}

szmstdst 发表于 2023-2-16 10:48:25

0.计算机cpu只懂得二进制的0和1
1.机器语言
2.编译
3.编译型语言是编译器将源代码编译成汇编语言,再通过汇编语言编译器编译成机器语言,CPU直接读取执行指令。
解释型语言是由编译器将源代码变成中间代码,中间代码交给解释器逐字翻译给cpu读取。
4.可以
5.解释型编程语言是将源代码变成中间代码,此时可以到解释器进行翻译给cpu
6.密码 解码的过程
7.亲们,趁敌人吃饭时候,发动进攻

Fishhry 发表于 2023-2-16 12:41:43

{:5_91:}

jimmyno1 发表于 2023-2-16 14:20:17

结果显示乱码

iindesuka 发表于 2023-2-16 16:24:21

..
页: 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 [1847] 1848 1849 1850 1851 1852 1853 1854 1855 1856
查看完整版本: S1E2:第一个程序 | 课后测试题及答案