1678442536 发表于 2020-2-26 08:37:57

小甲鱼NB

aleilei 发表于 2020-2-26 10:32:54

谢谢

卜零凌 发表于 2020-2-26 10:42:13

回复

ccccc12 发表于 2020-2-26 10:51:24

嘿嘿

0110代码 发表于 2020-2-26 11:53:03

#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);
               
                return 0;
}

1920654181 发表于 2020-2-26 12:09:17

...

一帆船在飘 发表于 2020-2-26 13:29:05

本帖最后由 一帆船在飘 于 2020-2-26 13:32 编辑

1.机器码
2.编译
3.解释型语言需要编译器,但可跨平台。
4.不可以
5.需要编码器
6.二进制,编码和解码
7.亲们,趁敌人吃饭时,发动进攻。

lishicheng 发表于 2020-2-26 13:30:37

快看看答案

徐伟鹏 发表于 2020-2-26 13:39:17

129

时喵s 发表于 2020-2-26 13:49:08

为什么第52行sprintf(target, "%s/%s", path, fa.name);报错?

AliceLian 发表于 2020-2-26 13:51:50

支持

无敌神鹰 发表于 2020-2-26 14:35:09

11

国王与乞丐 发表于 2020-2-26 15:15:37

6

凛凛清风 发表于 2020-2-26 15:34:16

{:7_136:}

zzzh 发表于 2020-2-26 15:41:38

看看

huojj 发表于 2020-2-26 15:49:48

看答案

nagisawarm 发表于 2020-2-26 16:03:48

谢谢鱼C

wawcold 发表于 2020-2-26 16:08:04

前来学习

绿豆蛙11 发表于 2020-2-26 16:11:51

答案

SaoboSaMa 发表于 2020-2-26 16:21:47

答案
页: 582 583 584 585 586 587 588 589 590 591 [592] 593 594 595 596 597 598 599 600 601
查看完整版本: S1E2:第一个程序 | 课后测试题及答案