张鹏程 发表于 2020-8-12 17:29:17

我来了

ljh156 发表于 2020-8-12 17:45:09

。。

kac 发表于 2020-8-12 17:49:03

查看参考答案

Peach_WYY 发表于 2020-8-12 18:04:00

很好!

幸福你我他 发表于 2020-8-12 19:27:50

1

728252187 发表于 2020-8-12 20:54:15

emmmm,不一样。

zephyrzzz 发表于 2020-8-12 21:07:34

来对一下答案~

Vulgarian 发表于 2020-8-12 21:54:25

1

秋歌久雨 发表于 2020-8-12 22:04:04

开始学习!

淡泊十年 发表于 2020-8-12 23:00:14

82 哪里我一直错
82        23        C:\Users\Lenovo\Desktop\未命名1.cpp        'findALLDirs' was not declared in this scope我不知道为什么求助一下

我爱学习147 发表于 2020-8-12 23:09:25

看答案

南方233 发表于 2020-8-12 23:44:13

0.二进制
1.机器语言
2.编译
3.
4.不能
5.
6.加密

hitman 发表于 2020-8-12 23:44:28

做笔记做笔记

世界破坏时 发表于 2020-8-13 00:06:15

让我康康让我康康让我康康

Dixie 发表于 2020-8-13 01:10:50

本帖最后由 Dixie 于 2020-8-13 12:47 编辑


#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("jisuanzhong...\n");
               
                findAllCodes(path);
                findALLDirs(path);
               
                printf("muqiannizonggongxiele%1dhangdaima!\n\n",total);
                system("pause");
               
                return 0;
}

LLX2020 发表于 2020-8-13 09:43:33

为什么一定要回复

小甲鱼姐姐 发表于 2020-8-13 10:25:26

1

小甲鱼姐姐 发表于 2020-8-13 10:30:34

为什么我报错了啊,我复制的啊

Zot3 发表于 2020-8-13 10:51:13

查看

可爱小白的主人 发表于 2020-8-13 11:14:15

学习
页: 800 801 802 803 804 805 806 807 808 809 [810] 811 812 813 814 815 816 817 818 819
查看完整版本: S1E2:第一个程序 | 课后测试题及答案