范ter嘻 发表于 2021-1-16 22:49:53

1

APower-YR 发表于 2021-1-16 23:49:57

{:10_256:}

RapidRunner 发表于 2021-1-16 23:57:02

获取答案

与山间之明月 发表于 2021-1-17 01:04:45

{:10_297:}

gdfsjunjun 发表于 2021-1-17 02:29:07

感谢楼主无私奉献!

dongruizheng 发表于 2021-1-17 03:35:08

第一节

modafirst 发表于 2021-1-17 10:35:15

#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((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("目前你总共写了 %1d 行代码!\n\n",total);

    system("pause");

    return 0;
}

尼禄的男朋友 发表于 2021-1-17 10:37:49

0.计算机只能认识0或者1
1.机器语言
2.编译
3.
4.可以
5.解释型语言编译后翻译成字节码文件,该字节码文件在各个平台上翻译出的文件不一样,因此可以跨平台
6.编码
7.

OLY56 发表于 2021-1-17 13:00:19

自己思考和动手

OLY56 发表于 2021-1-17 13:10:32

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

寻寻幂幂 发表于 2021-1-17 13:25:09

想看答案

feronia 发表于 2021-1-17 14:15:04

101

小义c 发表于 2021-1-17 14:52:47

看答案

bigash 发表于 2021-1-17 14:58:29

来学习了

linjunjie125801 发表于 2021-1-17 15:01:46

看看

世界和平 发表于 2021-1-17 15:10:52

回复

laikankan 发表于 2021-1-17 15:40:12

顶顶顶

2799153122 发表于 2021-1-17 15:40:16

我是老王啊啊啊 发表于 2021-1-17 15:58:45

完成

chaoser 发表于 2021-1-17 16:17:30

我爱小甲鱼
页: 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 [1016] 1017 1018 1019 1020 1021 1022 1023 1024 1025
查看完整版本: S1E2:第一个程序 | 课后测试题及答案