小鱼佬 发表于 2024-7-6 12:42:24

想知道

孤身一人¥ 发表于 2024-7-6 14:39:36

hello world

ZDY19990921 发表于 2024-7-6 14:45:05

查看参考答案

sleep冰 发表于 2024-7-6 17:15:45

完成

无敌肥猫 发表于 2024-7-6 17:38:45

{:10_277:}

Lll05 发表于 2024-7-6 18:41:30

1

15216501270 发表于 2024-7-6 23:03:23

好难好多报错

2974865801 发表于 2024-7-7 07:36:25

0. 只识别0和1
1.机器语言
2.编译
3.可不可跨平台
4.不可
5.解释器
6.字符频率
7.
QINMEN
CHEND
IRENC
HIFAN
SHIF
ADONG
JINGO
NG

2974865801 发表于 2024-7-7 07:38:13

#include<stdio.h>
#include<direct.h>
#include<io.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;
}

安然宝宝 发表于 2024-7-7 22:25:26

嘿嘿嘿

xxcjcy 发表于 2024-7-8 10:54:13

1462804040 发表于 2024-7-8 12:58:22

看看答案

JayChou0 发表于 2024-7-8 17:07:22

0:计算机只懂0和1;
1:机器语言;
2:编译;
3:后者需要翻译;
4:可以;
5:解释器;
6:编码,解码;

JayChou0 发表于 2024-7-8 17:09:51

1

番木可 发表于 2024-7-8 20:31:55

好耶

幺二零 发表于 2024-7-9 03:10:32

system(“pause”)的system是个未定义标识符。。。

rzdezhu 发表于 2024-7-9 10:58:19

开始学习了

LXIN001 发表于 2024-7-9 13:24:41

1

Fc7584758 发表于 2024-7-9 17:30:16

1

juezei 发表于 2024-7-9 17:53:51

666
页: 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 [2036] 2037 2038 2039 2040 2041 2042 2043 2044 2045
查看完整版本: S1E2:第一个程序 | 课后测试题及答案