New-day.Lee 发表于 2020-4-6 16:03:08

目前你总共写了 100 行代码!

hakali 发表于 2020-4-6 16:49:36

怎么一直报错

Taxol 发表于 2020-4-6 17:20:31

查看参考答案

Hongshu53 发表于 2020-4-6 17:39:47

谢谢楼主

小麻雀飞了 发表于 2020-4-6 17:42:22

66

w171744 发表于 2020-4-6 17:49:52

感谢

椕雅 发表于 2020-4-6 19:05:14

0.那就是呀,毋庸置疑!
1.机器语言
2.编译
3.解释性语言是指它常用的执行机制是使用一个“解释器”来执行,解释器对于程序是一句一句“翻译”成机器语言来一句一句执行。
编译型语言是指它常用的执行机制是使用一个“编译器”来编译成机器语言,然后你就可以直接运行(执行)这个编译成的“可执行文件”。
4.能行
5.编译器
6.查表
7.QINGN CHEND IRENC HIFAF SHIF ADONG JINGO NG
动动手:计算中…目前你总写了101行代码!

行行行 发表于 2020-4-6 19:07:50

康康

小明远 发表于 2020-4-6 21:48:15

亲们 ChenDiRren吃饭时发动进攻

Kav1n 发表于 2020-4-6 23:07:40

{:10_257:}

FCcool丶 发表于 2020-4-7 09:35:11

查看参考答案

浮生123 发表于 2020-4-7 09:37:09

答案?

a聪明叶 发表于 2020-4-7 10:04:40

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

伯牙君 发表于 2020-4-7 10:21:58

8行

Sunshine丶苏杨 发表于 2020-4-7 11:37:12

yuzu666 发表于 2020-4-7 13:34:01

感谢分享!

长大后当太空人 发表于 2020-4-7 13:38:35


.

sakurainn 发表于 2020-4-7 15:22:54

查看参考答案

湖城丶逍遥 发表于 2020-4-7 16:15:54

学习学习

1305539097 发表于 2020-4-7 17:12:17

hh
页: 652 653 654 655 656 657 658 659 660 661 [662] 663 664 665 666 667 668 669 670 671
查看完整版本: S1E2:第一个程序 | 课后测试题及答案