孤独枫 发表于 2022-11-11 10:09:29

总共写了0行代码?

孤独枫 发表于 2022-11-11 10:12:38



显示只敲了0行代码

pc073957 发表于 2022-11-11 12:06:01

查看学习

Bayuxin 发表于 2022-11-11 14:45:16

s

Czl_huanting 发表于 2022-11-11 15:41:34

nice
有题才是好教材

zhaohandi 发表于 2022-11-11 17:10:53

1111

2722017809 发表于 2022-11-11 20:12:23

0.0

一锅粥 发表于 2022-11-11 21:20:45


#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, traget;
       
        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 _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);
                       findAllDirs(thePath);
               }
       }while (_findnext(handle, &fa) == 0);
       
       _findclose(handle);
}

int main()
{
        char path = ".";
       
        printf("计算中...\n");
       
        findAllCodes(path);
        findAllDirs(path);
       
        printf("目前你总共写了 %1d 行代码! \n\n", total);
        system("pause");
       
        return 0;
}

c2691643910 发表于 2022-11-12 09:27:54

z

Lxx81192 发表于 2022-11-12 15:28:41

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

Yale.Xu 发表于 2022-11-12 15:31:17

;;

ccc阿晓 发表于 2022-11-12 16:26:44

111

着迷烟火 发表于 2022-11-12 16:57:51

第一个就这么离谱吗

uyy019 发表于 2022-11-12 18:20:47

1qq

1915218790 发表于 2022-11-12 18:28:12

0没得感情
101机器语言
2编译
3解释型语言不直接编译成机器码,而是将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU 来执行
4可以
5解释器
6查表
7我爱苍老师

ayy2515 发表于 2022-11-12 19:39:00

感谢分享

whd168168 发表于 2022-11-12 20:48:14

你好帅

1xxxx1 发表于 2022-11-12 22:32:41

回复

DICES007 发表于 2022-11-12 23:04:18

111

derekf 发表于 2022-11-12 23:16:44

加油
页: 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 [1799] 1800 1801 1802 1803 1804 1805 1806 1807 1808
查看完整版本: S1E2:第一个程序 | 课后测试题及答案