leechi 发表于 2025-8-29 20:39:42

5

竹秋 发表于 2025-8-29 21:10:09

{:5_111:}

Lingzhongyi 发表于 2025-8-30 02:29:51

{:5_111:}

吴宏喆 发表于 2025-8-30 15:09:58

报道报道

Youyong20041009 发表于 2025-8-31 10:17:36

n

Songllan 发表于 2025-9-2 15:17:36

oi

iko 发表于 2025-9-2 20:52:18

有意思

StormPoint 发表于 2025-9-3 18:06:21

鱼C有你更精彩^_^

hedaren_fc 发表于 2025-9-4 13:19:06

{:5_111:}

冯卿安 发表于 2025-9-4 13:34:53

答案

Loading_123 发表于 2025-9-5 17:24:28

加油

HUOHUON 发表于 2025-9-5 20:09:39

1.计算机只识别机械语言
2.机械语言
3.编码
4.可以
5.
6.查表

qaq628 发表于 2025-9-5 23:04:53

#include<io.h>
#include<unistd.h>
#include<direct.h>
#include<stdlib.h>
#include<string.h>
#include<sys/stat.h>

#define MAX      256

long total;

int countlines(const char *filename);
void findAllCodes(const char *path);
void findALLDirs(const char *path);

int countLines(const char *filename0)
{
                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)
{
        struch _finddata_t fa;
        long handle;
        char thrPath;
       
        strcpy(thePath,path);
        if((handle = _findfirst(strcat(thePath,"/*.c"),&fa)) != -1L)
        {
                do
                {
                        sprintf(target, "%s/%s", path,fa.name);
                        total +=countLINRS(target);
                }while (_findnext(handle, &fa) == 0);
        }
       
        _findclose(handle);
}

void findALLDirs(const char *path)
{
        stru _finddate_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);
                }
        }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;
}

dj5207 发表于 2025-9-6 12:19:46

1

fawn1162 发表于 2025-9-6 22:37:23

S1E2:第一个程序 |课后测试题及答案 [修改]
高级模式

fish.z 发表于 2025-9-7 21:48:34

1

广斤 发表于 2025-9-8 16:46:20


Anonymous_ade 发表于 2025-9-9 17:09:24

支持

kikiki452 发表于 2025-9-9 21:06:29

1

曹某 发表于 2025-9-9 21:46:12

{:9_238:}
页: 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 [2112] 2113 2114 2115 2116 2117 2118 2119 2120 2121
查看完整版本: S1E2:第一个程序 | 课后测试题及答案