JDjindi 发表于 2021-9-7 20:11:52

1

源代码丶 发表于 2021-9-7 20:27:04

来看答案咯

wtfyl 发表于 2021-9-7 20:27:23

666

JJLau 发表于 2021-9-7 21:41:26

a

burntlime 发表于 2021-9-7 22:51:51

只认识0, 1
机器
编译
是否可直接执行


映射关系

LittleYyy 发表于 2021-9-7 23:19:55

11

354283757 发表于 2021-9-8 00:22:28

char path = ".";
      
      printf("计算中...\n");
      
      findAllCodes(path);
      findALLDirs(path);
      
      printf("目前你总共写了 %ld 行代码!\n\n", total);
      system("pause");
      
      return 0;

yudingzhang 发表于 2021-9-8 04:27:55

顶顶顶

247517695 发表于 2021-9-8 10:41:19

1

爱学习的小P 发表于 2021-9-8 11:18:43

1

学不会就坐牢 发表于 2021-9-8 12:38:38

..

面向码农编程 发表于 2021-9-8 12:58:50

1.机器语言

妙龄少女守护者 发表于 2021-9-8 13:09:57

6666

huxiaokun 发表于 2021-9-8 14:00:29

111

二百圆 发表于 2021-9-8 14:23:50


layueshiba 发表于 2021-9-8 15:22:02

答案

lidahai0323 发表于 2021-9-8 16:27:17

有两处怎么检查都是错误的,是一样的检查了好多遍一摸一样为甚恶魔运行不了呢

qiyuewuxi 发表于 2021-9-8 16:35:05

0.因为计算机只能处理0和1
1.C
2.编译
3.是否要翻译成机器语言
4.不一定
5.借助同一个程序来来理解你的语言
6.通过0和1还有 的不同排列顺序来表达不同的字母,数字,及符号

710622542 发表于 2021-9-8 16:49:02

朕很开心

657302413 发表于 2021-9-8 17:07:03

#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX          256

long total;

int countLines(const char *fliename);
void findAllCodes(const char *path);
void findAllFilles(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;
}
页: 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 [1355] 1356 1357 1358 1359 1360 1361 1362 1363 1364
查看完整版本: S1E2:第一个程序 | 课后测试题及答案