长渊 发表于 2016-6-2 12:33
写的随堂代码 只能输出 :请输入分数 输入分数后没反应 不知道原因 ,呼叫小甲鱼老师
#includ ...
是不是忘按回车了?
可以的,学习了!
打卡
爱你哦,鱼鱼
谢谢
害我又多学了几个英文单词{::}
棒棒哒
我们老师给我们说了个软件raport,带有一个恐龙的图标,这个画流程图也很方便。
说错了,叫raptor
ProcessOn 也收费了 {:5_104:}
学废了
小甲鱼 真的棒
厉害厉害,考试的时候就考流程图设计程序,学会!{:10_256:}
第一节课的课后作业那个统计代码的程序为什么我的一直都是0,我没有安装虚拟机,敲得代码直接存放在桌面新建文件夹的
感谢!!!
感谢大佬的分享
pynliu 发表于 2017-7-11 17:24
行行好,送点鱼币吧
鱼币可以送吗?
Axel-F 发表于 2016-1-22 18:23
小甲鱼老师之前有一个统计打了多少行代码的程序,我找不到在哪了?
能发个链接吗?
#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;
}
呐,兄弟拿去,拿走不谢~~
长渊 发表于 2016-6-2 12:33
写的随堂代码 只能输出 :请输入分数 输入分数后没反应 不知道原因 ,呼叫小甲鱼老师
#includ ...
很显然啦,scanf的引号里不能有\n,不然C语言君会默认输入的东东里包含回车,这样就永远也没法输入啦(迟到五年的帮助orz)
xkl