MrChAJ 发表于 2023-6-22 19:05:55

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

WhenHx 发表于 2023-6-22 20:45:31

计算机只认识0和1 两个数字,唯一认识机器语言。

光呀! 发表于 2023-6-22 22:01:35

计算中...
目前你总共写了143行代码!

请按任意键继续. . .

@leee 发表于 2023-6-23 09:47:44

down

@leee 发表于 2023-6-23 10:08:48

macOS系统使用Xcode编程代码,显示
the path scm.plist is wrong!
the path OpenQuickly-ReferencedFrameworks.index-v1 is wrong!
the path Logs is wrong!
the path TextIndex is wrong!
the path Index is wrong!
the path Build is wrong!
the path info.plist is wrong!
the path Intermediates.noindex is wrong!
the path Products is wrong!
the path Debug is wrong!
the path Xcode C is wrong!
目前你总共写了0行代码!

Program ended with exit code: 0
(其中the path *** is wrong!有很多行,这是其中一小部分)

鱼与白日梦 发表于 2023-6-23 11:03:43

验证正误

恩骨不是骨恩 发表于 2023-6-23 12:38:06

I love FishC.com

zr宇 发表于 2023-6-23 16:14:26

6

陈9527 发表于 2023-6-23 16:48:22


#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);
        system("pause");
       
        return 0;
       
}

吃鱼丸 发表于 2023-6-23 22:58:22

看答案

CPrimerPlus 发表于 2023-6-23 23:47:35

啊,这

小石厨 发表于 2023-6-24 01:02:51

1

盒子学C 发表于 2023-6-24 01:31:01

看答案

sunp 发表于 2023-6-24 09:45:26




1

henCOOL 发表于 2023-6-24 17:00:46

111

k-on! 发表于 2023-6-24 20:09:28

1

k-on! 发表于 2023-6-25 08:35:38

1

1596853458 发表于 2023-6-25 10:25:10

学习第一天

水稻本尊 发表于 2023-6-25 12:17:24

答案

dai_shu 发表于 2023-6-25 13:55:46

0 二进制 1机器语言 2编码 3 一个是一次性全编译 一个是一条条翻译 4 可以 5      6 编码解码7
页: 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 [1905] 1906 1907 1908 1909 1910 1911 1912 1913 1914
查看完整版本: S1E2:第一个程序 | 课后测试题及答案