Board logo

标题: 523066680编辑区 [打印本页]

作者: 523066680     时间: 2009-2-13 18:49    标题: 523066680编辑区


@echo off &setlocal enabledelayedexpansion
set /p inp=" : "
call :funa na %inp%
call :funa nb %inp:* =%


set /a lpna=0,lpr=-1
:lpna
set /a lpna+=1,lpnb=0,lpr+=1,lp=lpr
  :lpnb
  set /a lpnb+=1,lp+=1
  ::::::::::::::::::::::::::
    set /a cup%lp%+=na%lpna%*nb%lpnb%
     set /a tlpa=lp,tlpb=tlpa+1
     :cuplp
     set /a cup%tlpb%+=cup%tlpa%/10,cup%tlpa%=cup%tlpa%%%10
     if !cup%tlpb%! gtr 9 (
        set /a tlpa+=1,tlpb=tlpa+1
        goto :cuplp
     ) else (if !cup%tlpb%! equ 0 set /a tlpb-=1)

  ::::::::::::::::::::::::::
  if %lpnb% lss %nb% (goto :lpnb)
if %lpna% lss %na% (goto :lpna)

for /l %%a in (%tlpb%,-1,1) do set /p=!cup%%a!<nul
echo,
echo,wscript.echo %inp: =*%>x.vbs
cscript //nologo x.vbs
pause>nul &exit


:funa
set %1=%2
set funaa=0
:funaa
  set /a funaa+=1
  set %1%funaa%=!%1:~-%funaa%,1!
if not "!%1:~%funaa%!"=="" (goto :funaa)
set /a %1=funaa
版本2
@echo off &setlocal enabledelayedexpansion
set /p inp=" : "
call :naxnb %inp%
pause

:naxnb
set numa=%1
set numb=%2
set /a la=0,lpr=-1
:la
set /a la+=1,lb=0,lpr+=1,lp=lpr
  :lb
  set /a lb+=1,lp+=1,tlpa=lp,tlpb=lp+1
  :::::::::::::::::::::::::
  set /a cup%lp%+=!numa:~-%la%,1! * !numb:~-%lb%,1!
     :cuplp
     set /a cup%tlpb%+=cup%tlpa%/10,cup%tlpa%=cup%tlpa%%%10
     if !cup%tlpb%! gtr 9 (
        set /a tlpa+=1,tlpb=tlpa+1
        goto :cuplp
     ) else (if !cup%tlpb%! equ 0 set /a tlpb-=1)
  ::::::::::::::::::::::::::
  if not "!numb:~%lb%!"=="" (goto :lb)
if not "!numa:~%la%!"=="" (goto :la)
for /l %%a in (%tlpb%,-1,1) do set /p=!cup%%a!<nul

::::::::vbs验证一下:::::::::::
echo,
echo,wscript.echo %inp: =*%>x.vbs
cscript //nologo x.vbs
pause>nul &exit
[ Last edited by 523066680 on 2009-2-21 at 10:46 ]
作者: 523066680     时间: 2009-2-13 18:50
2016-09 更新链接地址:

  Quote:
文章

[讨论]Batch Rename's Bug
http://www.cn-dos.net/forum/viewthread.php?tid=45655

[讨论]TalkAboutString
http://www.cn-dos.net/forum/viewthread.php?tid=45654

[分享][讨论]段落重定向方式改进
http://www.cn-dos.net/forum/viewthread.php?tid=45409

[讨论]2次ping1 不等于 1次ping2
http://www.cn-dos.net/forum/viewthread.php?tid=45410

[分享]%var%代替语句执行
http://www.cn-dos.net/forum/viewthread.php?tid=45240

贪吃蛇思路解析 (23楼)
http://www.cn-dos.net/forum/viewthread.php?tid=43369

建立永久的畸形盘符
http://www.cn-dos.net/forum/viewthread.php?tid=41796


数学相关:

[原创]批处理算24点
http://www.cn-dos.net/forum/viewthread.php?tid=45488

[数值计算]1-99内整数开根
http://www.cn-dos.net/forum/viewthread.php?tid=43046

应用:

[已解决]能否更改批处理脚本的进程名称? (已找到解答,在24楼链接。)
http://www.cn-dos.net/forum/viewthread.php?tid=42169

[求助]如何用脚本实现待机?打开屏保?
http://www.cn-dos.net/forum/viewthread.php?tid=45522

[原创]批处理脚本打包工具
http://www.cn-dos.net/forum/viewthread.php?tid=44620

[vbs]满1小时就关机
http://www.cn-dos.net/forum/viewthread.php?tid=45242

[分享]生成待编写的测试脚本
http://www.cn-dos.net/forum/viewthread.php?tid=45250

[原创]举出当前最小和最大的bat文件
http://www.cn-dos.net/forum/viewthread.php?tid=41517

[原创]001,002,003式的批量重命名
http://www.cn-dos.net/forum/viewthread.php?tid=41643


娱乐,特效:

[特效]数字阵逐点显现,随机
http://www.cn-dos.net/forum/viewthread.php?tid=45878

[原创]批处理写大字效果--新年贺卡
http://www.cn-dos.net/forum/viewthread.php?tid=45411

动画特效:画圆、弹球、进度条、起落等
http://www.cn-dos.net/forum/viewthread.php?tid=42124

[原创]纯批处理版贪吃蛇
http://www.cn-dos.net/forum/viewthread.php?tid=43369

[原创]中间渐渐变大的圆
http://www.cn-dos.net/forum/viewthread.php?tid=44785

空间随机游动粒子+贪吃蛇初版
http://www.cn-dos.net/forum/viewthread.php?tid=43059

【视觉类】前进中的道路+飞机大炮
http://www.cn-dos.net/forum/viewthread.php?tid=41333

【视觉类】从中间逐渐扩大再变小的方形框框+变色   
http://www.cn-dos.net/forum/viewthread.php?tid=40711

时钟--斜体+毫秒(更新,减少cpu和闪烁)   
http://www.cn-dos.net/forum/viewthread.php?tid=41833

[原创]潜水数天,完成了自己满意的数码雨
http://www.cn-dos.net/forum/viewthread.php?tid=42113

【算是月贴】我尽量减少闪烁的批处理大时钟
http://www.cn-dos.net/forum/viewthread.php?tid=41757

[动画]一路小跑,第一集,跳!
http://www.cn-dos.net/forum/viewthread.php?tid=41981

做了一个自己满意的滚动字幕
http://www.cn-dos.net/forum/viewthread.php?tid=39780


回帖:

【挑战】用批处理画出正方形和抛物线   14楼  15楼 18楼
http://bbs.bathome.cn/thread-3537-2-1.html

  [出题]批处理趣味数学之n阶蛇形方阵  28楼
http://www.cn-dos.net/forum/viewthread.php?tid=42472

  [已结]怎样生成一个纯数字的密码字典 6楼
http://www.cn-dos.net/forum/viewthread.php?tid=33139

  [已结]排列组合  27楼
http://www.cn-dos.net/forum/viewthread.php?tid=41243


水区:

[分享]徒手编数独阵
http://www.cn-dos.net/forum/viewthread.php?tid=45817

以歧视之道还治歧视之身
http://www.cn-dos.net/forum/viewthread.php?tid=45986

523066680语录
http://www.cn-dos.net/forum/viewthread.php?tid=46304

[分享][转载]半截故事
http://www.cn-dos.net/forum/viewthread.php?tid=45521

光速矛盾
http://www.cn-dos.net/forum/viewthread.php?tid=44789

1=0.9999999……?  
http://www.cn-dos.net/forum/viewthread.php?tid=43058

文章

[讨论]Batch Rename's Bug
http://www.cn-dos.net/forum/viewthread.php?tid=45655

[讨论]TalkAboutString
http://www.cn-dos.net/forum/viewthread.php?tid=45654

[分享][讨论]段落重定向方式改进
http://www.cn-dos.net/forum/viewthread.php?tid=45409

[讨论]2次ping1 不等于 1次ping2
http://www.cn-dos.net/forum/viewthread.php?tid=45410

[分享]%var%代替语句执行
http://www.cn-dos.net/forum/viewthread.php?tid=45240

贪吃蛇思路解析 (23楼)
http://www.cn-dos.net/forum/viewthread.php?tid=43369

建立永久的畸形盘符
http://www.cn-dos.net/forum/viewthread.php?tid=41796


数学相关:

[原创]批处理算24点
http://www.cn-dos.net/forum/viewthread.php?tid=45488

[数值计算]1-99内整数开根
http://www.cn-dos.net/forum/viewthread.php?tid=43046

应用:

[已解决]能否更改批处理脚本的进程名称? (已找到解答,在24楼链接。)
http://www.cn-dos.net/forum/viewthread.php?tid=42169

[求助]如何用脚本实现待机?打开屏保?
http://www.cn-dos.net/forum/viewthread.php?tid=45522

[原创]批处理脚本打包工具
http://www.cn-dos.net/forum/viewthread.php?tid=44620

[vbs]满1小时就关机
http://www.cn-dos.net/forum/viewthread.php?tid=45242

[分享]生成待编写的测试脚本
http://www.cn-dos.net/forum/viewthread.php?tid=45250

[原创]举出当前最小和最大的bat文件
http://www.cn-dos.net/forum/viewthread.php?tid=41517

[原创]001,002,003式的批量重命名
http://www.cn-dos.net/forum/viewthread.php?tid=41643


娱乐,特效:

[特效]数字阵逐点显现,随机
http://www.cn-dos.net/forum/viewthread.php?tid=45878

[原创]批处理写大字效果--新年贺卡
http://www.cn-dos.net/forum/viewthread.php?tid=45411

动画特效:画圆、弹球、进度条、起落等
http://www.cn-dos.net/forum/viewthread.php?tid=42124

[原创]纯批处理版贪吃蛇
http://www.cn-dos.net/forum/viewthread.php?tid=43369

[原创]中间渐渐变大的圆
http://www.cn-dos.net/forum/viewthread.php?tid=44785

空间随机游动粒子+贪吃蛇初版
http://www.cn-dos.net/forum/viewthread.php?tid=43059

【视觉类】前进中的道路+飞机大炮
http://www.cn-dos.net/forum/viewthread.php?tid=41333

【视觉类】从中间逐渐扩大再变小的方形框框+变色   
http://www.cn-dos.net/forum/viewthread.php?tid=40711

时钟--斜体+毫秒(更新,减少cpu和闪烁)   
http://www.cn-dos.net/forum/viewthread.php?tid=41833

[原创]潜水数天,完成了自己满意的数码雨
http://www.cn-dos.net/forum/viewthread.php?tid=42113

【算是月贴】我尽量减少闪烁的批处理大时钟
http://www.cn-dos.net/forum/viewthread.php?tid=41757

[动画]一路小跑,第一集,跳!
http://www.cn-dos.net/forum/viewthread.php?tid=41981

做了一个自己满意的滚动字幕
http://www.cn-dos.net/forum/viewthread.php?tid=39780


回帖:

【挑战】用批处理画出正方形和抛物线   14楼  15楼 18楼
http://bbs.bathome.cn/thread-3537-2-1.html

  [出题]批处理趣味数学之n阶蛇形方阵  28楼
http://www.cn-dos.net/forum/viewthread.php?tid=42472

  [已结]怎样生成一个纯数字的密码字典 6楼
http://www.cn-dos.net/forum/viewthread.php?tid=33139

  [已结]排列组合  27楼
http://www.cn-dos.net/forum/viewthread.php?tid=41243


水区:

[分享]徒手编数独阵
http://www.cn-dos.net/forum/viewthread.php?tid=45817

以歧视之道还治歧视之身
http://www.cn-dos.net/forum/viewthread.php?tid=45986

523066680语录
http://www.cn-dos.net/forum/viewthread.php?tid=46304

[分享][转载]半截故事
http://www.cn-dos.net/forum/viewthread.php?tid=45521

光速矛盾
http://www.cn-dos.net/forum/viewthread.php?tid=44789

1=0.9999999……?  
http://www.cn-dos.net/forum/viewthread.php?tid=43058

  Quote:
文章  [讨论]Batch Rename's Bug http://www.cn-dos.net/forum/viewthread.php?tid=45655  [讨论]TalkAboutString http://www.cn-dos.net/forum/viewthread.php?tid=45654  [分享][讨论]段落重定向方式改进 http://www.cn-dos.net/forum/viewthread.php?tid=45409  [讨论]2次ping1 不等于 1次ping2 http://www.cn-dos.net/forum/viewthread.php?tid=45410  [分享]%var%代替语句执行 http://www.cn-dos.net/forum/viewthread.php?tid=45240  贪吃蛇思路解析 (23楼) http://www.cn-dos.net/forum/viewthread.php?tid=43369  建立永久的畸形盘符 http://www.cn-dos.net/forum/viewthread.php?tid=41796   数学相关:  [原创]批处理算24点 http://www.cn-dos.net/forum/viewthread.php?tid=45488  [数值计算]1-99内整数开根 http://www.cn-dos.net/forum/viewthread.php?tid=43046  应用:  [已解决]能否更改批处理脚本的进程名称? (已找到解答,在24楼链接。) http://www.cn-dos.net/forum/viewthread.php?tid=42169  [求助]如何用脚本实现待机?打开屏保? http://www.cn-dos.net/forum/viewthread.php?tid=45522  [原创]批处理脚本打包工具 http://www.cn-dos.net/forum/viewthread.php?tid=44620  [vbs]满1小时就关机 http://www.cn-dos.net/forum/viewthread.php?tid=45242  [分享]生成待编写的测试脚本 http://www.cn-dos.net/forum/viewthread.php?tid=45250  [原创]举出当前最小和最大的bat文件 http://www.cn-dos.net/forum/viewthread.php?tid=41517  [原创]001,002,003式的批量重命名 http://www.cn-dos.net/forum/viewthread.php?tid=41643   娱乐,特效:  [特效]数字阵逐点显现,随机 http://www.cn-dos.net/forum/viewthread.php?tid=45878  [原创]批处理写大字效果--新年贺卡 http://www.cn-dos.net/forum/viewthread.php?tid=45411  动画特效:画圆、弹球、进度条、起落等 http://www.cn-dos.net/forum/viewthread.php?tid=42124  [原创]纯批处理版贪吃蛇  http://www.cn-dos.net/forum/viewthread.php?tid=43369  [原创]中间渐渐变大的圆 http://www.cn-dos.net/forum/viewthread.php?tid=44785  空间随机游动粒子+贪吃蛇初版 http://www.cn-dos.net/forum/viewthread.php?tid=43059  【视觉类】前进中的道路+飞机大炮 http://www.cn-dos.net/forum/viewthread.php?tid=41333  【视觉类】从中间逐渐扩大再变小的方形框框+变色    http://www.cn-dos.net/forum/viewthread.php?tid=40711  时钟--斜体+毫秒(更新,减少cpu和闪烁)    http://www.cn-dos.net/forum/viewthread.php?tid=41833  [原创]潜水数天,完成了自己满意的数码雨 http://www.cn-dos.net/forum/viewthread.php?tid=42113  【算是月贴】我尽量减少闪烁的批处理大时钟 http://www.cn-dos.net/forum/viewthread.php?tid=41757  [动画]一路小跑,第一集,跳! http://www.cn-dos.net/forum/viewthread.php?tid=41981  做了一个自己满意的滚动字幕 http://www.cn-dos.net/forum/viewthread.php?tid=39780   回帖:   【挑战】用批处理画出正方形和抛物线   14楼  15楼 18楼 http://bbs.bathome.cn/thread-3537-2-1.html    [出题]批处理趣味数学之n阶蛇形方阵  28楼 http://www.cn-dos.net/forum/viewthread.php?tid=42472    [已结]怎样生成一个纯数字的密码字典 6楼 http://www.cn-dos.net/forum/viewthread.php?tid=33139    [已结]排列组合  27楼 http://www.cn-dos.net/forum/viewthread.php?tid=41243   水区:  [分享]徒手编数独阵 http://www.cn-dos.net/forum/viewthread.php?tid=45817  以歧视之道还治歧视之身 http://www.cn-dos.net/forum/viewthread.php?tid=45986  523066680语录 http://www.cn-dos.net/forum/viewthread.php?tid=46304  [分享][转载]半截故事 http://www.cn-dos.net/forum/viewthread.php?tid=45521  光速矛盾 http://www.cn-dos.net/forum/viewthread.php?tid=44789  1=0.9999999……?   http://www.cn-dos.net/forum/viewthread.php?tid=43058

[ Last edited by 523066680 on 2016-9-28 at 11:42 ]
作者: 523066680     时间: 2009-2-17 18:15
My exist  .   仅仅是exist.
作者: 523066680     时间: 2009-2-17 18:42

@echo off &setlocal enabledelayedexpansion
set /p inp=" : "
call :funa na %inp%
call :funa nb %inp:* =%


set /a lpna=0,lpr=-1
:lpna
set /a lpna+=1,lpnb=0,lpr+=1,lp=lpr
  :lpnb
  set /a lpnb+=1,lp+=1
  ::::::::::::::::::::::::::
    set /a axb=na%lpna%*nb%lpnb%
    set /a cup%lp%=axb+cup%lp%
    if !cup%lp%! gtr 9 (set "do=") else (set do=::)

    %do% set /a tlpa=lp,tlpb=tlpa+1
    %do% :cuplp
    %do% set /a cup%tlpa%=cup%tlpa%-10,cup%tlpb%+=1
    %do% set /a tlpa+=1,tlpb=tlpa+1
    %do% if !cup%tlpb%! gtr 9 (goto :cuplp)

  ::::::::::::::::::::::::::
  if %lpnb% lss %nb% (goto :lpnb)
if %lpna% lss %na% (goto :lpna)


for /l %%a in (1,1,8) do echo !cup%%a!

set /a temp=1234*1234
echo %temp%
pause>nul &exit


:funa
set /a %1=%2,funaa=0
:funaa
  set /a funaa+=1
  set %1%funaa%=!%1:~-%funaa%,1!
if not "!%1:~%funaa%!"=="" (goto :funaa)
set /a %1=funaa

作者: 523066680     时间: 2009-2-20 18:49
@echo off &setlocal enabledelayedexpansion
title code by 523066680
set /p inp="输入两个乘数 空格隔开: "
call :naxnb %inp%
pause
:naxnb
set numa=%1
set numb=%2
set /a la=0,lb=0,lp=0

:la
set /a la+=1,lb+=1,lp+=1

  set /a lb+=1,tlpa=lp,tlpb=lp+1
  :::::::::::::::::::::::::
  set /a cup%lp%+=!numa:~-%la%,1! + !numb:~-%lb%,1!
     :cuplp
     set /a cup%tlpb%+=cup%tlpa%/10,cup%tlpa%=cup%tlpa%%%10
     if !cup%tlpb%! gtr 9 (
        set /a tlpa+=1,tlpb=tlpa+1
        goto :cuplp
     ) else (if !cup%tlpb%! equ 0 set /a tlpb-=1)

  ::::::::::::::::::::::::::

if not "!numb:~%lb%!"=="" (goto :la)
if not "!numa:~%la%!"=="" (goto :la)
for /l %%a in (%tlpb%,-1,1) do set /p=!cup%%a!<nul
::::::::vbs验证一下:::::::::::
echo,
echo,wscript.echo %inp: =+%>x.vbs
cscript //nologo x.vbs
pause>nul &exit

[ Last edited by 523066680 on 2009-2-21 at 11:29 ]
作者: 523066680     时间: 2009-3-7 06:27
@echo off&setlocal enabledelayedexpansion
set /a sa=63456,sb=61426
:a
echo, %sb:~1,1%
echo,%sa:~1,3%
echo, %sb:~3,1%
echo,
echo, %sb:~0,1%
echo,&echo,
set /p inp="(w a s d): "
echo,
if %inp% equ w (
  set sb=%sb:~1%%sb:~1,1%
)
if %inp% equ s (
  set sb=%sb:~3,1%%sb:~0,4%
)
if %inp% equ a (
  set sa=%sa:~1%%sa:~1,1%
)
if %inp% equ d (
  set sa=%sa:~3,1%%sa:~0,4%
)
goto :a
作者: 523066680     时间: 2009-6-3 05:24

typedef struct
{
int fa,fb;
} fraction;


char axb[3];

fraction arr[4];
fraction outvar;
int whox[3];
int overa;

void arrangement(int a[],int n);
void next(fraction a[],int n);
void count(fraction a,int x,fraction b,int n);

main()
{
int i,ma[4];
for (i=0;i<4;i++) arr[i].fb=1;
while (1)
{
  printf("______________________\nPress [Ctrl+C] = Quit \n\n");
  printf("Input 4 numbers,such as: 3 3 8 8 : ");
  scanf("%d %d %d %d",&ma[0],&ma[1],&ma[2],&ma[3]);
  overa=0;
  arrangement(ma,4);
  if (overa==0) printf("\n Not result!\n\n");
}
getch();
}

void arrangement(int a[],int n)
{
  int temp[4];
  int i,j,k;
  if (n==0)
  {
    next(arr,4);
    return;
  }
  for (i=0;i<n;i++)
  {  k=0;
     arr[4-n].fa=a[i];
     for (j=0;j<n;j++) {if (i!=j) temp[k++]=a[j];}
     arrangement(temp,n-1);
  }
}


void next(fraction a[],int n)
{
  int i,j;
  fraction temp[4];
  if ((overa==0)&&(n==1)&&(a[0].fa==24*a[0].fb))
  {printf("\n    ");
   if (whox[1]==0)
   {
     if (whox[0]==0)
     {printf("[(%d %c %d) %c %d] %c %d",arr[0].fa,axb[0],arr[1].fa,axb[1],arr[2].fa,axb[2],arr[3].fa);}
     else if (whox[0]==1)
     {printf("[%d %c (%d %c %d)] %c %d",arr[0].fa,axb[1],arr[1].fa,axb[0],arr[2].fa,axb[2],arr[3].fa);}
     else if (whox[0]==2)
     {printf("(%d %c %d) %c (%d %c %d)",arr[0].fa,axb[1],arr[1].fa,axb[2],arr[2].fa,axb[0],arr[3].fa);}
   }
   else
   {
     if (whox[0]==0)
     {printf("(%d %c %d) %c (%d %c %d)",arr[0].fa,axb[0],arr[1].fa,axb[2],arr[2].fa,axb[1],arr[3].fa);}
     else if (whox[0]==1)
     {printf("%d %c [(%d %c %d) %c %d]",arr[0].fa,axb[2],arr[1].fa,axb[0],arr[2].fa,axb[1],arr[3].fa);}
     else if (whox[0]==2)
     {printf("%d %c [%d %c (%d %c %d)]",arr[0].fa,axb[2],arr[1].fa,axb[1],arr[2].fa,axb[0],arr[3].fa);}

   }
   printf(" = 24 \n\n");
   overa=1;
   return;
  }
  for (i=0;i<n-1;i++)
  {
   whox[4-n]=i;
   for (j=0;j<n;j++){temp[j].fa=a[j].fa;temp[j].fb=a[j].fb;}
   for (j=i+1;j<n-1;j++){temp[j].fa=temp[j+1].fa;temp[j].fb=a[j+1].fb;}
   for (j=0;j<4;j++)
   {
     count(a[i],j,a[i+1],n);
     temp[i].fa=outvar.fa;
     temp[i].fb=outvar.fb;
     if (outvar.fb!=0) next(temp,n-1);
   }
  }
}

void count(fraction a,int x,fraction b,int n)
{

  if (x==0)
  {
    axb[4-n]='+';
    outvar.fa=(a.fa*b.fb)+(b.fa*a.fb);
    outvar.fb=a.fb*b.fb;
  }
  else if (x==1)
  {
    axb[4-n]='-';
    outvar.fa=(a.fa*b.fb)-(b.fa*a.fb);
    outvar.fb=a.fb*b.fb;
  }
  else if (x==2)
  {
    axb[4-n]='*';
    outvar.fa=a.fa*b.fa;
    outvar.fb=a.fb*b.fb;
  }
  else if (x==3)
  {
    axb[4-n]='/';
    outvar.fa=a.fa*b.fb;
    outvar.fb=a.fb*b.fa;
  }
}
附件 1: COUNT24B.rar (2009-6-3 05:26, 7.78 K, 下载附件所需积分 1点 ,下载次数: 1)

作者: 523066680     时间: 2009-7-7 23:33    标题: 二维管道


#include "Conio.h"
#include "graphics.h"
#include "stdlib.h"
#define closegr closegraph

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

int main(void)
{
  int a,b,x,y,i,j;
  randomize();
  initgr(); /* BGI初始化 */
  x=y=200;
  for (i=1;i<=15;i++)
  {
   a=rand()%600+1;b=rand()%400+20;

   putpixel(x,y,4);
   while (x!=a||y!=b)
   {
     if (x<a)
       x++;
     else if (x>a)
       x--;
     else
     {
       if (y<b)
         y++;
       else if (y>b)
         y--;
     }
     for (j=0;j<=100;j++) delay(10);
     putpixel(x,y,i);
   }
  }
  rectangle(x-5,y-5,x+5,y+5);

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}

作者: 523066680     时间: 2009-7-7 23:57    标题: 随机游蛇


#include "Conio.h"
#include "graphics.h"
#include "stdlib.h"
#define closegr closegraph

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

int main(void)
{
  int a,b,x,y,i,j,dtl=50,dtn=0;
  int dot[50][2];
  randomize();
  initgr(); /* BGI初始化 */
  x=y=200;
  dot[dtn][0]=dot[dtn][1]=200;

  for (i=1;i<dtl;i++) {dot[i][0]=0;dot[i][1]=0;}
  for (i=1;i<=15;i++)
  {
   a=rand()%600+1;b=rand()%400+20;

   putpixel(x,y,4);
   while (x!=a||y!=b)
   {
     if (x<a)
       x++;
     else if (x>a)
       x--;
     else
     {
       if (y<b)
         y++;
       else if (y>b)
         y--;
     }
     for (j=0;j<=100;j++) delay(10);
     putpixel(x,y,i);

     if (dtn<(dtl-1)) dtn++;
     else dtn=0;

     if (dot[dtn][0]!=0) putpixel(dot[dtn][0],dot[dtn][1],0);
     dot[dtn][0]=x;dot[dtn][1]=y;
   }
  }
  rectangle(x-5,y-5,x+5,y+5);

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}

作者: 523066680     时间: 2009-7-13 00:07    标题: 多条随机游动的snake


#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NSNK 5
#define LONG 60

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

int main(void)
{
  int i,j;
  struct {
   int a,b,x,y,dtl,dtn,dot[LONG][2];
  } snk[NSNK];

  initgr(); /* BGI初始化 */

  for (i=0;i<NSNK;i++) {
   snk[i].a=snk[i].b=snk[i].x=snk[i].y=snk[i].dot[0][0]=snk[i].dot[0][1]=200;
   snk[i].dtl=LONG;
   snk[i].dtn=0;
   for (j=1;j<LONG;j++) {snk[i].dot[j][0]=snk[i].dot[j][1]=0;}
  }
  randomize();
  while (!kbhit())
  {
    for (i=0;i<150;i++) delay(10);
    for (i=0;i<NSNK;i++){
      putpixel(snk[i].x,snk[i].y,i+1);
      if ((snk[i].x==snk[i].a)&&(snk[i].y==snk[i].b)){
         snk[i].a=rand()%600+1;
         snk[i].b=rand()%400+20;
      }
    }
    for (i=0;i<NSNK;i++){
       if (snk[i].x>snk[i].a)
         snk[i].x--;
       else if (snk[i].x<snk[i].a)
         snk[i].x++;
       else
       {
           if (snk[i].y>snk[i].b)
             snk[i].y--;
           else if (snk[i].y<snk[i].b)
             snk[i].y++;
       }
     if (snk[i].dtn<(snk[i].dtl-1)) snk[i].dtn++;
     else snk[i].dtn=0;
     
     if (snk[i].dot[snk[i].dtn][0]!=0) putpixel(snk[i].dot[snk[i].dtn][0],snk[i].dot[snk[i].dtn][1],0);
     snk[i].dot[snk[i].dtn][0]=snk[i].x;
     snk[i].dot[snk[i].dtn][1]=snk[i].y;
    }


  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}
NLine
#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NSNK 5

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

int main(void)
{
  int i,j;
  struct {
   int a,b,x,y;
  } snk[NSNK];

  initgr(); /* BGI初始化 */

  for (i=0;i<NSNK;i++) {
   snk[i].a=snk[i].b=snk[i].x=snk[i].y=200;
  }
  randomize();
  while (!kbhit())
  {
    for (i=0;i<150;i++) delay(10);
    for (i=0;i<NSNK;i++){
      putpixel(snk[i].x,snk[i].y,i+1);
      if ((snk[i].x==snk[i].a)&&(snk[i].y==snk[i].b)){
         snk[i].a=rand()%600+1;
         snk[i].b=rand()%400+20;
      }
    }
    for (i=0;i<NSNK;i++){
       if (snk[i].x>snk[i].a)
         snk[i].x--;
       else if (snk[i].x<snk[i].a)
         snk[i].x++;
       else
       {
           if (snk[i].y>snk[i].b)
             snk[i].y--;
           else if (snk[i].y<snk[i].b)
             snk[i].y++;
       }
    }


  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}
5RandDot
#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NDOT 5

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

void func(int x,int y,int c)
{
  putpixel(x,y,c);
  putpixel(x+1,y,c);
  putpixel(x,y+1,c);
  putpixel(x+1,y+1,c);
}

int main(void)
{
  int i,j,whi=0;
  struct {
   int a,b,x,y,tx,ty;
  } snk[NDOT];

  initgr(); /* BGI初始化 */

  for (i=0;i<NDOT;i++) {
   snk[i].a=snk[i].b=snk[i].x=snk[i].y=200;
  }
  randomize();
  while (!kbhit())
  {
    if (whi<4) whi++; else whi=0;
    for (i=0;i<150;i++) delay(10);
    for (i=0;i<NDOT;i++){
      func(snk[i].tx,snk[i].ty,0);
      func(snk[i].x,snk[i].y,i+1);
      if ((snk[i].x==snk[i].a)&&(snk[i].y==snk[i].b)){
         snk[i].a=rand()%600+1;
         snk[i].b=rand()%400+20;
      }
    }
    for (i=0;i<NDOT;i++){
    snk[i].tx=snk[i].x;
    snk[i].ty=snk[i].y;
    if (whi>i) continue;
       if (snk[i].x>snk[i].a)
         snk[i].x--;
       else if (snk[i].x<snk[i].a)
         snk[i].x++;
       else
       {
           if (snk[i].y>snk[i].b)
             snk[i].y--;
           else if (snk[i].y<snk[i].b)
             snk[i].y++;
       }
    }


  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}
[ Last edited by 523066680 on 2009-7-13 at 22:18 ]
作者: 523066680     时间: 2009-7-13 22:31    标题: 变幻的三角形


#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NDOT 3

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

void delta(int xa,int ya,int xb,int yb,int xc,int yc,int c)
{
   setcolor(c);
   line(xa,ya,xb,yb);
   line(xa,ya,xc,yc);
   line(xb,yb,xc,yc);
}

int main(void)
{
  int i,j,whi=0;
  struct {
   int a,b,x,y,tx,ty;
  } snk[NDOT];

  initgr(); /* BGI初始化 */

  for (i=0;i<NDOT;i++) {
   snk[i].a=snk[i].b=snk[i].x=snk[i].y=200;
  }
  randomize();
  while (!kbhit())
  {
    if (whi<3) whi++; else whi=0;
    for (i=0;i<200;i++) delay(10);

    delta(snk[0].tx,snk[0].ty,snk[1].tx,snk[1].ty,snk[2].tx,snk[2].ty,0);
    delta(snk[0].x,snk[0].y,snk[1].x,snk[1].y,snk[2].x,snk[2].y,2);

    for (i=0;i<NDOT;i++){
      if ((snk[i].x==snk[i].a)&&(snk[i].y==snk[i].b)){
         snk[i].a=rand()%600+1;
         snk[i].b=rand()%400+20;
      }
    }
    for (i=0;i<NDOT;i++){
    snk[i].tx=snk[i].x;
    snk[i].ty=snk[i].y;
    if (whi>i) continue;
       if (snk[i].x>snk[i].a)
         snk[i].x--;
       else if (snk[i].x<snk[i].a)
         snk[i].x++;
       else
       {
           if (snk[i].y>snk[i].b)
             snk[i].y--;
           else if (snk[i].y<snk[i].b)
             snk[i].y++;
       }
    }


  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}

作者: 523066680     时间: 2009-7-13 23:07    标题: 变幻的四面体


#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NDOT 4


typedef struct
{
   int a,b,x,y;
} DotInf;


void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

void delta(DotInf dot[],int c)
{
   int i,j;
   setcolor(c);
     for (i=0;i<NDOT;i++)
       for (j=i+1;j<NDOT;j++) line(dot[i].x,dot[i].y,dot[j].x,dot[j].y);
}

int main(void)
{
  int i,j,whi=0;
  DotInf snk[NDOT],everdot[NDOT];

  initgr(); /* BGI初始化 */

  for (i=0;i<NDOT;i++) {
   snk[i].a=snk[i].b=snk[i].x=snk[i].y=200;
  }
  delta(snk,2);
  randomize();
  while (!kbhit())
  {
    if (whi<4) whi++; else whi=0;
    for (i=0;i<600;i++) delay(10);

    delta(everdot,0);
    delta(snk,2);

    for (i=0;i<NDOT;i++){
      if ((snk[i].x==snk[i].a)&&(snk[i].y==snk[i].b)){
         snk[i].a=rand()%600+1;
         snk[i].b=rand()%400+20;
      }
    }
    for (i=0;i<NDOT;i++){
    everdot[i].x=snk[i].x;
    everdot[i].y=snk[i].y;
    if (whi>i) continue;
       if (snk[i].x>snk[i].a)
         snk[i].x--;
       else if (snk[i].x<snk[i].a)
         snk[i].x++;
       else
       {
           if (snk[i].y>snk[i].b)
             snk[i].y--;
           else if (snk[i].y<snk[i].b)
             snk[i].y++;
       }
    }


  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}
[ Last edited by 523066680 on 2009-8-23 at 07:13 ]
作者: 523066680     时间: 2009-7-14 03:06    标题: 密密麻麻的虫子……


#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}
int main(void)
{
  int i,j;
  initgr(); /* BGI初始化 */

  randomize();
  while (!kbhit())
  {
     for (j=200;j<=300;j++)
     {
      putpixel(rand()%400+1,j,4);
      putpixel(rand()%400+1,j,0);
     }
     for (j=0;j<200;j++) delay(10);
  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}
狂轰滥炸的感觉~  乱弄出来的
#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph

void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

void func(int x,int y,int c)
{ setcolor(c);
  rectangle(x-4,y-4,x+4,y+4);
}
int main(void)
{
  int i,j;
  initgr(); /* BGI初始化 */

  randomize();

  while (!kbhit())
  {
   for (i=1;i<=30;i++)
   {
     for (j=1;j<=30;j++) if (rand()%30>20) func(j*10,i*10,1);
     for (j=1;j<=30;j++) if (rand()%30>10) func(j*5,i*5,0);
   }
   for (j=0;j<500;j++) delay(20);
  }
  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}
[ Last edited by 523066680 on 2009-7-14 at 03:26 ]
作者: 523066680     时间: 2009-8-2 10:06


[ Last edited by 523066680 on 2009-8-2 at 10:09 ]
作者: 523066680     时间: 2009-8-18 09:39
看来不合格的文本操作代码,我自个儿先留着。 处理的文本为text.txt

过80字节转一行,字符处理可以,效率不好。
@echo off
err>result.x 2>nul
set /a x=0
for /f "delims= eol=#" %%a in (text.txt) do (
   set /a x+=1
   set /a seta=0,setb=80
   echo,    %%a>x.x
   call :func
)
start result.x
pause
exit

:func
   echo,Sentence%x%
   type x.x>temp.x
   fsutil file setzerodata offset=0 length=%seta% temp.x     >nul
   fsutil file setzerodata offset=%setb% length=10000 temp.x >nul
   (for /f "delims= eol=#" %%c in ('more temp.x') do (echo,%%c>temp.x))||goto :eof
   for /f "tokens=3" %%a in ('dir temp.x /-c ^|find "个文件"') do (set num=%%a)
   set /a seta=seta+num-2,setb=seta+80 &type temp.x>>result.x &goto :func
goto :eof
[ Last edited by 523066680 on 2009-8-18 at 09:41 ]
作者: 523066680     时间: 2009-8-23 07:19    标题: Delta2


#include <Conio.h>
#include <graphics.h>
#include <stdlib.h>
#define closegr closegraph
#define NDOT 3


typedef struct
{
   int a,b,x,y;
} DotInf;


void initgr(void) /* BGI初始化 */
{
  int gd = DETECT, gm = 0;
  registerbgidriver(EGAVGA_driver);
  initgraph(&gd, &gm, "");
}

void delta(DotInf dot[],int c)
{
   int i,j;
   setcolor(c);
     for (i=0;i<NDOT;i++)
     for (j=i+1;j<NDOT;j++)
     {line(dot[i].x,dot[i].y,dot[j].x,dot[j].y);}
}

int main(void)
{
  int i,j,whi=0,edotn=0;
  DotInf snk[NDOT];
  DotInf edot[10][NDOT];
   for (i=0;i<9;i++) for (j=0;j<NDOT-1;j++) {edot[i][j].x=edot[i][j].y=0;}

  initgr(); /* BGI初始化 */

  for (i=0;i<NDOT;i++) {
   snk[i].a=snk[i].b=snk[i].x=snk[i].y=200;
   edot[edotn][i].x=edot[edotn][i].y=200;
  }
  randomize();
  while (!kbhit())
  {
    if (edotn<9) edotn++; else edotn=0;
    if (whi<NDOT) whi++; else whi=0;
    for (i=0;i<400;i++) delay(15);
    if (edot[edotn][i].x!=0) delta(edot[edotn],0);
    delta(snk,2);

    for (i=0;i<NDOT;i++){
      if ((snk[i].x==snk[i].a)&&(snk[i].y==snk[i].b)){
         snk[i].a=rand()%600+1;
         snk[i].b=rand()%400+20;
      }
    }
    for (i=0;i<NDOT;i++){
    if (whi>i) continue;
       if (snk[i].x>snk[i].a)
         snk[i].x--;
       else if (snk[i].x<snk[i].a)
         snk[i].x++;
       else
       {
           if (snk[i].y>snk[i].b)
             snk[i].y--;
           else if (snk[i].y<snk[i].b)
             snk[i].y++;
       }

    edot[edotn][i].x=snk[i].x;
    edot[edotn][i].y=snk[i].y;

    }


  }

  getch();
  closegr(); /* 恢复TEXT屏幕模式 */
  return 0;
}

作者: 523066680     时间: 2009-8-23 07:20    标题: 时间随机按位显示


@echo off
setlocal enabledelayedexpansion
mode con cols=25 lines=5
title %date%
set "str=xxxxxxxx"
:a
set t=%time:~0,8%
call :next
ping -n 3 127.1>nul
set "t=        "
call :next
goto :a

   :next
    for /l %%a in (0,1,7) do (set num%%a=%%a)
    set /a aa=8
    :aa
     set /a rand=%random%%%aa,aa-=1
     set /a x=num%rand%,xb=x+1
     set str=!str:~0,%x%!!t:~%x%,1!!str:~%xb%!
     set num%rand%=!num%aa%!
     ping -n 1 127.1>nul
     cls
     echo,   %str%
    if %aa% gtr 0 (goto :aa)
   goto :eof
[ Last edited by 523066680 on 2009-8-23 at 07:22 ]
作者: 523066680     时间: 2009-9-3 09:11
把一个自然数分解成  n个连续自然数。
@echo off
:a
set "inp="
set /p inp="input a number: "
set /a act=2,end=inp/2,inp*=10,the500=1,the001=1
:lp
set /a x=inp/act,xx=inp%%act,xxx=act%%2
if defined the%x:~-1%%xx%%xxx% (call :func %x:~-1%)
if %act% lss %end% (set /a act+=1 &goto :lp)
pause &goto :a

:func
set /a a=(x-%1)/10-(act-1)/2,b=(x+%1)/10+(act-1)/2
if %a% lss 0 (set /a end=0 &goto :eof)
for /l %%a in (%a%,1,%b%) do set /p= %%a<nul
echo,&echo, &goto :eof
组成的数中有负数的:
@echo off
:a
set /p inp="input a number: "
set /a act=2,end=inp/2,inp*=10,the500=1,the001=1
:lp
set /a x=inp/act,xx=inp%%act,xxx=act%%2
if defined the%x:~-1%%xx%%xxx% (call :func %x:~-1%)
if %act% lss %end% (set /a act+=1 &goto :lp)
pause &set "inp=" &goto :a

:func
set /a a=(x-%1)/10-(act-1)/2,b=(x+%1)/10+(act-1)/2
for /l %%a in (%a%,1,%b%) do set /p= %%a<nul
echo,&echo, &goto :eof
列出1000左右不能拆分位n个连续自然数的:
@echo off
set /a inp=0,the500=1,the001=1
:a
set /a inp+=1,act=2,end=inp/2,inp*=10,have=0
:lp
  set /a x=inp/act,xx=inp%%act,xxx=act%%2
  if defined the%x:~-1%%xx%%xxx% (set /a inp/=10 &goto :a)
  if %act% lss %end% (set /a act+=1 &goto :lp)
set /a inp/=10
echo,%inp%
if %inp% lss 1000 goto :a
pause

作者: 523066680     时间: 2009-9-15 22:30    标题: [TestCscript]ListErrLines


set wsx=createobject("wscript.shell")
if wscript.arguments.count = 0 then
  wsx.run "cmd /c cscript " &wscript.scriptname & " 1 &pause>nul"
  wscript.quit
end if

checkfile="test1.vbs"
argu=""
set start=wsx.exec("cscript " &checkfile &argu)
set errinfo=start.stderr
set echo=wscript.stdout

x=errinfo.readline

if x="" then
echo.writeline "No error information."
else
str=""
echo.writeline ""
t1=split(x,",")
tt1=split(t1(0),"(")
tt2=split(t1(1),")")
y=tt1(1) : x=tt2(0)
for i = 2 to x
   str=str & " "
next
echo.writeline "Filename: " & tt1(0)
echo.writeline "ErrInfo : " & tt2(1)
echo.writeline "(Lines = " &y &" , cols =" &x & ")"
echo.writeline str & "↓"

set readx=createobject("scripting.filesystemobject").opentextfile(checkfile,1)
for i = 2 to y
   readx.readline
next
echo.writeline readx.readline
if readx.atendofstream then
    echo.writeline "Check Info: End of line."
else
    for i = 1 to 4
      if readx.atendofstream = false then
         echo.writeline readx.readline
      end if
    next
end if
read.xclose
end if

echo.write vbcrlf &"Press any key to continue..."
echo.close
wscript.quit

作者: 523066680     时间: 2009-11-20 20:09
今天很无聊……
@echo off
setlocal enabledelayedexpansion
for /l %%a in (1,1,40) do (set spc=  !spc!)
set strx=%spc: =x%
for /l %%a in (1,1,20) do (set ln%%a=%spc%)
set /a a=-20
:a
set inp=%a:-=%
set /a n=inp*2,stra=(80-n)/2,la=(24-inp)/2,a+=2
for /l %%a in (1,1,1) do (ping -n 1 127.1>nul)
cls
for /l %%a in (1,1,%la%) do (echo, )
for /l %%a in (1,1,%inp%) do (echo,!spc:~-%stra%!!strx:~-%n%!)
if %a% geq 20 set a=-20
goto :a
作者: 523066680     时间: 2010-1-6 19:34    标题: [shell日记]read

[shell日记]read
文:523066680
今天第一篇。
算是一种笔记吧,就像流水帐一样
算不上分享,因为每个人都会经历自己探索的过程。

顺便学英语,就把原帮助一起拉上来

参数和对应实例:
-a array        assign the words read to sequential indices of the array
                    variable ARRAY, starting at zero   
把输入内容按分隔符(空格或者跳格之类)分配给数组,连续的空格也算为1个分割。
输入后,数组规格跟c语言一样,用var[n]的格式表示,下标从0开始,
直接echo $var 的效果等于echo ${var[0]}
当echo 数组带下标的时候,记得加{}表达,比如echo ${a[1]}
定义数组变量: read -a arr  就可以了;  read -a arr[1] 出错。
但是你直接 read arr[1] 是允许的,就是直接赋值数组某个元素嘛。

-d delim        continue until the first character of DELIM is read, rather
                    than newline
就是读取输入,直到某个字符出现为止,而不是转行结束。当然,“某个字符”不算进去。
测试结果:
1,  指定是某个字符后,回车也被读进去,而不会因回车结束
(嘿嘿,没试过该参数以回车字符结束,不会弄+多余)
2,  -dstr 不会到 str结束,是s结束,所以人家才说是character
3,  -dx str  ;# 转了n行+输入字符 ; echo $str 并不会把转行输出来
要echo "$str" 才会转行。

(以下不知道的都直接引用help内容)
-e  use Readline to obtain the line in an interactive shell
不知道,好像是默认的读取一行就结束?以后知道了补上

-i text    Use TEXT as the initial text for Readline

-n nchars        return after reading NCHARS characters rather than waiting
                    for a newline
                rather than 在这里指:而不是。
读取到了第N个字符就结束~ 而不是等待一个新的行。
结果按回车将提前结束了 [ 感觉没有-d 那么严,还说nchars]
感觉描述的不严密, 实际规则是{ 如果 转行||字符数为n ;则 结束 }
(这个参数的help一度让我以为rather than是或者的意思)

-p prompt  prompt就是提示的意思,就是先显示"prompt"字符串,在后面等待你输入。
                 有提示选项就不用另外echo提示啦。

-r                do not allow backslashes to escape any characters
             backslash 反斜杠 "\";
             escape    逃脱;在这里指:转义
             翻译:不允许反斜杠来转义任何字符。

-s                do not echo input coming from a terminal
             不显示正在从终端输入的字符。(就像输入密码时),
             说真的,想象不到-s跟这功能的联系,学它就像背书一样

-t timeout        time out and return failure if a complete line of input is
                    not read withint TIMEOUT seconds.  The value of the TMOUT
                    variable is the default timeout.  TIMEOUT may be a
                    fractional number.  If TIMEOUT is 0, read returns success only
                    if input is available on the specified file descriptor.  The
                    exit status is greater than 128 if the timeout is exceeded
             1.如果在 timeout 秒内一个还没写完(触发终止输入条件),就超时退出 + 命令会返回一个
             错误码。[不会真的提示错误,是返回错误代码。 echo $? ;我看到错误代号为 142]
             2.这句话没看出来,不过执行TMOUT=1, 命令行1秒后就退出了
             3.timeout 的值可以是一个分数[fractional number],当然并不是真的用分数表示法
             他是告诉你,可以使用一个非整数,比如 -t0.5  就是限制半秒内输入。
             4.如果设timeout为0,则仅当 从有效的特殊文件描述中输入 时返回成功。[看不出来]
             5.exceed 超出;如果超时,退出状态[退出代码]就大于128。
-u fd                read from file descriptor FD instead of the standard input
             不说了,都不知道fd是什么,相关资料:http://baike.baidu.com/view/1303430.htm
             “linux下,所有的操作都是对文件进行操作,而对文件的操作是利用文件描述符
              (file descriptor)来实现的。在源代码中,一般用fd作为文件描述符的标识。”


# 仍然不知道几个参数的含义,所以以后知道了会回来修改的…… #


终: read 后面不加变量名,会把值赋给REPLY这个变量,
但是,如果你给了一个新的变量名,REPLY不会同步更新。



+++++++++++++++++学点英语+++++++++++++
#1     -e        use Readline to obtain the line in an interactive shell
百度搜索:
obtain            获得;得到
实例: He failed to obtain a scholarship.  他没有获得奖学金。

interactive      互相作用的;交互式的

#2     -n nchars    return after reading NCHARS characters rather than waiting
            for a newline

rather than : 而不是

#3     -t timeout
                time out and return [failure] if a complete line of input is
                    not read withint TIMEOUT seconds.  The value of the TMOUT
                    variable is the default timeout.  TIMEOUT may be a
                    [fractional] number.  If TIMEOUT is 0, read returns success only
                    if input is available on the specified file descriptor.  The
                    exit status is greater than 128 if the timeout is [exceeded]

failure n. 失败
He was doomed to failure. 他注定失败

fractional 形容词:小量的;分数的

exceed  超过
作者: 523066680     时间: 2010-1-24 21:46
本来read -n1 就可以只读取一个字符,按键就下一句了。
我写了一个循环read -n1 的  就是按任意键继续重复这一操作,为了让循环等待我的确认。

结果 按下 键盘"右键"  一下子循环n次,  原来这些方向键等的,按一下就值好几个字符
害我一下循环n 次…… (变成某个键n次了吗 O_o)

所以再整个 `read -n9 -t0.1`  ,在read -n1 前面, 也就是:
在读取一个字符后,
0.1秒内,不管有没有9个字符,都吃掉他
(我以为-t0可以瞬间吃掉,结果发现还是有一个按键下来,出现的几个字符还是有时间差的,就0.1了)
#!/bin/bash

while true
do
  g++ -o wasdq -lglut wasdq.c
  ./wasdq
  echo "Press any key to continue"
  read -s -n1 REPLY
  read -t0.1 -n9
done
试了下,吃字符的话直接 read -t0.1  是不行的, 他只等待0.1秒 而不读取字符
(因为默认是以回车键来作输入结束)
照理说会造成 无限循环,而不等待,单这里只连续循环了几次。
差点忘了,原来是前面有个 read -n1  在每次循环中读取一个字符~。

同时感觉到了 -n 这个选项 来读取n个字符的时候,打破以 Enter 结束输入的限制。
-t -n 就是“或”限制了~   (超时)||(读取到n个字符的时候)  则 结束
=================================================================
改下变成 q 键退出的
#!/bin/bash

while true
do
  g++ -o wasdq -lglut wasdq.c
  ./wasdq
  echo "Press any key to continue"
  read -s -n1 REPLY
  read -t0.1 -n9 other
  if [ "$REPLY" == "q" ]; then exit ;fi
done
[ Last edited by 523066680 on 2010-1-24 at 22:14 ]
作者: 523066680     时间: 2010-3-14 22:27    标题: [批处理]备份目录系的更新

本来用xcopy就可以更新备份目录系到 我的移动硬盘了
但是xcopy只负责复制的,所以每次备份的时候有增无减

虽然可以先全部删除而后xcopy,这样节省代码,但复制时更消耗时间。

于是增加了一段代码,删除 源目录没有而备份目录有的东西
采用for 结合dir 遍历目录树,

判断如果是目录就 rd 目录系,如果是文件就 delete (判断句 if exist "%%a\" )
但是第一次的时候出了错,原因是:  

    有的主目录已经删除了,所以其下的目录系和文件也被删除了,
而dir出的目录系是不更新的,仍然会列出其子目录,就造成了子目录已经不存在
却还继续执行删除的错误。

所以在每个删除操作执行前又增加了一判断:该目标是否存在。

特性: 如果用于备份的目的磁盘不存在,会提前退出
如果成功执行,会生成删除文件的日志。
先删除,后xcopy
@echo off
rem code by 523066680@cn-dos.net
setlocal enabledelayedexpansion
set source=%~dp0
set dest=d:\烧录文件更新区

rem 源路径可以是自身路径,考虑到输入和%~dp0都可能出现末尾有\的情况,
rem 增加了判断及处理

if "%source:~-1%"=="\" (set source=%source:~0,-1%)
if "%dest:~-1%"=="\" (set dest=%dest:~0,-1%)

if not exist "%source%\" (
   echo 源[目录]不存在,按任意键退出
   pause>nul
   exit
)

echo 请确认: 源目录 %source%
echo 备份到 %dest%
if not exist "%dest%\" (
  echo 作为备份的目录%dest%  不存在,将尝试建立。
  (md "%dest%")||(
    echo 目标不能建立,可能是目标磁盘不存在,按任意键退出。
    pause>nul
    exit
  )
  goto :justcopy
)

type nul>DelFile.txt
type nul>DelFold.txt

echo _
echo 按任意键开始搜索+清理 "%dest%"中可能多出的文件或子文件夹
pause>nul
echo _

for /f "tokens=*" %%a in ('dir /a /s /b "%dest%"') do (
  set pathname=%%a
  set pathname=!pathname:%dest%\=!
  if exist "%%a" (
      if not exist %source%\!pathname! (
            if exist "%%a\" (
                 rd /s /q "%%a"
                 echo Remove directory : %%a>>DelFold.txt
            ) else (
                 del /f /s /a /q "%%a">>DelFile.txt
            )
      )
  )
)
echo 本次清理生成日志 DelFold.txt DelFile.txt
type "DelFold.txt" "Delfile.txt"

:justcopy
echo _
echo 按任意键继续开始XCOPY...
pause>nul
echo _
  if exist cut.txt (
    xcopy /s /d /c /h /exclude:cut.txt  "%source%" "%dest%"
  ) else (
    xcopy /s /d /c /h "%source%" "%dest%"
  )
echo 按任意键退出
pause>nul
exit
我知道有些软件可以实现,但是批处理的好处就在于可以自己实现一些细节操作,
比如 /exclude:cut.txt 参数,用来指定cut.txt文本中列出的文件名或者文件夹
不被拷贝。

[ Last edited by 523066680 on 2010-3-20 at 12:17 ]
作者: 523066680     时间: 2010-4-13 11:14

@echo off
setlocal enabledelayedexpansion
::为了减少判断+名字编号部分整齐(统一两位编号),文件个数不能大于99呢,即指定了01-99
::初步验证
if "%~1"=="" (
  echo 您没有拖入文件到我身上,于是第一个参数为空,按任意键拜拜~
  pause>nul
  exit
) else (
  if exist "%~1" (
    echo 拖放文件所在文件夹 "%~dp1"
    echo _
    set /p "inp=批量重命名之前,请指定名字前缀:"
    set /a n=1
    set "nx=000!n!"
    set "xformat=%~x1"
    set "xpath=%~dp1"
  ) else (echo 有参数但不对头,拜拜 &pause>nul &exit)
)

::如果%~1非空,且是存在的,才会到达这里
:main
if not "%~1"=="" (
   if exist "%~1" (
      echo 执行的操作: ren "%~nx1" "!inp!!n!%~x1%#"
      ren "%~1" "!inp!!nx:~-2!%~x1%#"
      set /a n+=1
      set nx=000!n!
   ) else (echo "%~1" is not exist)
   shift /1
   goto :main
) else (
   echo 现在还原格式 ren "%xpath%*%xformat%#" "*%xformat%"
   ren "%xpath%*%xformat%#" "*%xformat%"
   pause
   exit
)

作者: yonghu111     时间: 2010-4-13 15:30
感谢分享啦啊!!
作者: 523066680     时间: 2010-5-23 18:47    标题: 让OPENGL通过读取脚本绘图

读取脚本,并可以通过向脚本a.x  追加指令,继续描点着色,观察

着是雏形,只识别三道指令:
color red,green,blue
point x,y,z
sleep time
/* Directscript  Reader , code by 523066680, 20100522 */

#include <stdio.h>
#include <GL/glut.h>
#include <stdlib.h>

#define xpix 500
#define ypix 500

int winid;
float deepa=-1.0,deepb=1.0;

FILE *openx;



void display(void)
{
   static int clear=0;
   if (clear==0) { glClear(GL_COLOR_BUFFER_BIT); clear=1; }
   glutSwapBuffers();
}


void reshape(int wx,int wy)
{
   glViewport(0,0,wx,wy);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0,xpix,0.0,ypix,1.0,-1.0);
   glMatrixMode(GL_MODELVIEW);
}

void hitkey(unsigned char key,int mousex,int mousey)
{
    switch(key) {
      case 'q':
         glutDestroyWindow(winid);
         exit(0);
         break;
    }
}

void init(void)
{
   glClearColor(0.0,0.0,0.0,0.0);
   glPointSize(10);
   if ((openx=fopen("./a.x","r"))==NULL) {
       printf("File not exist !");
       exit(0);
   }

}


int main(int argc,char *argv[])
{
     void readfile(void);
/*CreateGraphWindow*/
     glutInit(&argc,argv);
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
     glutInitWindowPosition(0,0);
     glutInitWindowSize(xpix,ypix);
     winid=glutCreateWindow("dict");
     init();
     glutReshapeFunc(reshape);
     glutKeyboardFunc(hitkey);
     glutDisplayFunc(display);
     glutIdleFunc(readfile);
     glutMainLoop();

     return 0;
}

void readfile(void)
{
    int code;
    enum command {color,sleep,point} cmd;
    float a,b,c;
    char str[10];
    int apology(char *tmpstr);
        fscanf(openx,"%s ",str);
        if (!feof(openx)) {
          code=apology(str);
          switch (code) {
          case color :
            printf("read color : ");
            fscanf(openx,"%f,%f,%f",&a,&b,&c);
            printf("%f %f %f\n",a,b,c);
            a=(int)a%100/100.0; b=(int)b%100/100.0; c=(int)c%100/100.0;
            glColor3f(a,b,c);
            glutPostRedisplay();
            break;
          case sleep :
             printf("sleep!\n");
             fscanf(openx,"%f",&a);
             _sleep((int)(600 * a));
             break;
          case point :
             fscanf(openx,"%f,%f,%f",&a,&b,&c);
             if (c<deepa || c>deepb) {printf("ERR : z=%f , out of your window\n",c); }
             glBegin(GL_POINTS);
              glVertex3f(a,b,c);
             glEnd();
             glutPostRedisplay();
             printf("vertex3f: %f %f %f\n",a,b,c);
             break;
          default :
             printf("No this command\n");
             break;
          }
        } //else {usleep(600000.0);printf("end of text stream\n");}
}

int apology(char *tmpstr)
{
    int i,fo=3;
    char str[][10]={"color","sleep","point"};
    for (i=0;i<fo;i++) {
      if (strcmp(str[i],tmpstr)==0) {break;}
    }
    return i;
}
windows 下dev-cpp (含了glut库 ) 编译通过。

以下批处理生成随机指令,观察效果
@echo off
set dict=project1.exe

type nul>a.x

set /a n=0
:a
  set /a x=(%random% %%20) * 11,y=(%random% %%20) *11 ,z=0
  set /a a=%random% %%100,b=%random% %%100,c=%random% %%100
  echo color %a%,%b%,%c%  >>a.x
  echo point %x%,%y%,%z%  >>a.x
  echo sleep 0.1  >>a.x
if %n% lss 80 (set /a n+=1 &goto a)
echo 在图形窗口按q 可退出
start %dict%
pause
exit
我认为会是一个还可以的开始~

[ Last edited by 523066680 on 2010-5-23 at 18:50 ]
作者: 523066680     时间: 2010-6-9 19:38    标题: 个人写的记事工具


@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::
:: 临时记事,code by 523066680@cn-dos.net
::
:: 参数: add 记事内容         添加记事内容到记事列表
:: 参数: del 编号1 编号2 .... 删除指定编号的记事
:: 参数为空                   直接读取记事文本
::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal enabledelayedexpansion
set notebook=notebook.x
set arg_del=del
set arg_add=add
set arg_=type

if not exist "%notebook%" (
   echo %notebook% 不存在,将建立
   type nul>>notebook.x
   exit /b
)

if not defined arg_%1 (
   echo 指令 %1 不存在
   exit /b
) else (
   if "%1"=="" (goto :func_)
)

:read_it
::如果参数不为空就来到这里,增加项目编号和删除项目,都要先读取文本信息
::text format: $number $date $note , range of number : [0-99]
set /a note_n=0
for /f "tokens=1,2,*" %%a in ('type %notebook%') do (
   set note_info_#%%a=%%b %%c
   set /a note_n+=1
)
::然后才跳转到功能块
goto :func_%1


:func_
  type %notebook%
  exit /b

:func_del
  set /a x=-1
  if "%2"=="" (echo arg2 = NULL &exit /b)
  if not defined note_info_#%2 (echo no this item. &exit /b)
  ::假设删除一个以上项目,参数以空格的方式隔开,以总参数为字符串,用于判断
  for /f "tokens=1,*" %%a in ("%*") do (set note_items=%%b)
  ::像10这样的,删除的是0,单纯替换0以后也会变化,后面判断将进行删除,所以是危险的,增加判断因素
  set note_items=#%note_items: =#%#
  echo,>%notebook%
  for /f "tokens=2,* delims==#" %%a in ('set note_info_#') do (
    if "!note_items:#%%a#=!"=="!note_items!" (
       set /a x+=1
       set xnum=  !x!
       set xnum=!xnum:~-2!
       echo !xnum! %%b>>%notebook%
    ) else (
       echo 删除项 - %%a %%b
    )
  )
  echo %notebook% 重新排列 , 现状 :
  type %notebook%
  exit /b
:func_add
   if "%2"=="" (echo 附加信息为空 &exit /b)
   set xnum=  %note_n%
   set xnum=!xnum:~-2!
   set strnow=%*
   ::::cut string - "add "
   set strnow=%strnow:~4%
   (echo %xnum% %date:~0,10% %strnow%)>>%notebook%
   echo %notebook% 现状 :
   type %notebook%
   exit /b
测试:

  Quote:
c:\test>note add 这是个测试项
notebook.x 现状 :

0 2010-06-08 快递代收货款未到
1 2010-06-08 物料未清点
2 2010-06-09 制作一份供应商地址电话信息表
3 2010-06-09 这是个测试项

c:\test>note del 1 2
删除项 - 1 2010-06-08 物料未清点
删除项 - 2 2010-06-09 制作一份供应商地址电话信息表
notebook.x 重新排列 , 现状 :

0 2010-06-08 快递代收货款未到
1 2010-06-09 这是个测试项

c:\test>

[ Last edited by 523066680 on 2010-6-9 at 21:26 ]
作者: 523066680     时间: 2010-7-13 17:36    标题: 借Wget批量下载死神漫画

我是几十集没看的那种
你知道啦,在网上看很辛苦的,一张张翻,所以决定全都下载。
getpic.sh
#!/bin/bash
for ((fold=350;fold<=380;fold++))
do
   if [ ! -e $fold ]
   then
        mkdir $fold
   fi
   cd ./$fold
   wget --no-clobber http://178.manmankan.com/BLEACH/$fold/{001..025}.jpg
   cd ..
done
echo end
read -n1
死神一下看完了,于是下火影
由于工作的关系我经常跨系统,偷偷摸摸嘛,也整个批处理版的:
真羡慕bash支持 {1..4}=1 2 3 4 这样的扩展..... 改成批处理就粗起来了。
@echo off
setlocal enabledelayedexpansion
set name=naruto
for /l %%x in (420,1,500) do (
  if not exist %name%_%%x (md %name%_%%x)
  cd %name%_%%x
  for /l %%a in (1,1,25) do (
    set num=000%%a
    set num=!num:~-3!
    wget -nc http://140.manmankan.com/naruto/%%x/!num!.jpg
  )
  cd ..
)
最后这样用图片浏览器看着果然不舒服,批量导入网页吧
一集的图片列在一个页面,这样看一集翻一次就OK了。
@echo off
setlocal enabledelayedexpansion

for /l %%i in (420,1,500) do (
type nul>na_%%i.html
set /a left=%%i-1,right=%%i+1
echo ^<a href="na_!left!.html"^> 上一页 ^</a^> >>na_%%i.html
echo ^<a href="na_!right!.html"^> 下一页 ^</a^> ^<br^> >>na_%%i.html
for /l %%j in (1,1,25) do (
   set num=000%%j
   set num=!num:~-3!
   (
   echo ^<img src="naruto_%%i\!num!.jpg" /^>
   echo ^<br^>
   echo -----------------------------------------------------
   echo ^</br^>
   )>>na_%%i.html
)
echo ^<a href="na_!left!.html"^> 上一页 ^</a^> >>na_%%i.html
echo ^<br^> ^<a href="na_!right!.html"^> 下一页 ^</a^> >>na_%%i.html
echo %%i
)
pause
exit
[ Last edited by 523066680 on 2010-7-13 at 17:46 ]
作者: 523066680     时间: 2010-7-18 15:22    标题: H

执行顺序是:先MainGet.bat 然后Act.bat
其他两个是受调用的

MainGet.bat
先获取1-10张附有名单列表的页面,那里由我要的子页面
@echo off
set /a x=1
:main
wget -T 8 -t 1 主页_和谐/List/class_61_%x%.Html
if %x% lss 10 (set /a x+=1 &goto :main)
Act.bat
负责提取名单和子页地址,交给下载脚本
@echo off
setlocal enabledelayedexpansion
set /a i=1
:main
echo class_61_%i%
for /f "tokens=*" %%a in ('type class_61_%i%.html ^|find /i "span class"') do (
set str=%%a
set str=!str:*/html/=!
for /f "tokens=1 delims=." %%x in ("!str!") do (
      if not exist %%x (call downer.bat %%x)
)
)
if %i% lss 10 (set /a i+=1 &goto :main)
downer.bat     受act.bat调用
分析子页面中的图片链接,全部下载~
等等,节外生枝,为什么i % 3 = 1 和 2 时要外部调用下载呢
你知道啦,代码速度>下载速度, 外部调用,多进程下载就不用占时间了
取余为0时 ,当前进程下载,这是为了缓冲,如果全部调用外部,
没有缓冲,会变成炸弹脚本的。
@echo off
setlocal enabledelayedexpansion
set src=http://主页_被我和谐了/html/
set act=%1

:main
wget -T 5 -t 1 -nc %src%%act%.html
if %errorlevel% neq 0 (goto :eof)
if not exist %act% (mkdir %act%) else (goto :eof)
set /a i=0
cd %act%
for /f "tokens=2 delims= " %%a in ('type ..\%act%.html ^| find /i "img src"') do (
  set /a i+=1,p=i %% 3
  set str=%%a
  set str=!str:*http=!
  set str=!str:"=!
  set name=000!i!
  set name=!name:~-3!
  echo !name!
  if !p! equ 0 (
    wget -T 8 -t 1 -O !name!.jpg http!str!
    if !errorlevel! neq 0 (del !name!.jpg)
  ) else (
    start /min ..\geter.bat %cd% !name!.jpg http!str!
  )
)
cd ..
geter.bat
受 downer.bat调用
@echo off
echo %1 %2 %3
cd %1
wget -T 8 -nc -t 1 -O %2 %3
if %errorlevel% neq 0 (del %2)
exit
[ Last edited by 523066680 on 2010-7-19 at 12:34 ]
作者: 523066680     时间: 2010-7-30 20:18

::::::::::::::::::::::::::::::::::::::::::::::::::
:: code by 523066680@163.com
:: 从F盘开始,找出存在isme.x[标志性文件]的磁盘 Then
:: 读取isme.x内的相关目录名,并将当前目录更新备份到那里
:: 因为我的移动硬盘盘符时而变动,所以才写了一个根据标记文件寻找备份目的地的。
:: [源/目标]可能会有多个,所以find /i "目标信息",以匹配上正确的路径
:: 例isme.x内容 Files\me 表示终点为当前磁盘的files\me目录
::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal enabledelayedexpansion
set source=%~dp0
::寻在isme.x所在磁盘,找到就读取目标路径
for %%a in (f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\isme.x (
     for /f "tokens=*" %%s in ('type %%a:\isme.x ^|find /i "me"') do (
       set dest=%%s
       set dest=%%a:\!dest!
     )
)
)

if defined dest (goto :act) else (echo NOT FOUND &pause &exit)

:act
if "%source:~-1%"=="\" (set source=%source:~0,-1%)
if "%dest:~-1%"=="\" (set dest=%dest:~0,-1%)

if not exist "%dest%\" (
  echo 作为备份的目录%dest%  不存在,将尝试建立。
  (md "%dest%")||(
    echo 出错了...
    pause>nul
    exit
  )
  goto :justcopy
)

echo 正搜索+清理 "%dest%"中可能多出的文件或子文件夹
for /f "tokens=*" %%a in ('dir /a /s /b "%dest%"') do (
  set pathname=%%a
  set pathname=!pathname:%dest%\=!
  if exist "%%a" (
      if not exist %source%\!pathname! (
            if exist "%%a\" (
                 tree %%a
                 rd /s /q "%%a"
            ) else (
                 del /f /a /q "%%a"
            )
      )
  )
)

:justcopy
echo xcopying
if exist cut.txt (
   xcopy /f /s /d /c /h /y /exclude:cut.txt  "%source%" "%dest%"
) else (
   xcopy /f /s /d /c /h /y "%source%" "%dest%"
)
echo 按任意键退出
pause>nul
exit
[ Last edited by 523066680 on 2010-7-30 at 20:23 ]
作者: 523066680     时间: 2010-8-3 20:43


#include <BoysAndGirls.h>  /*人物性质*/
#include <Garden.h>   /*地点环境我想好了*/
#include <Action.h>    /*各种动作*/

int main(int time, char *BoysAndGirlsName[])
{
     New result;
     result=meet(boy("John"),girl("Alice"));
     printf("%s",result.body);   
     /*我YY打出一屏幕的字符,字符组成的是一对双胞胎 */
     /* return 2 , 如果输出的ML的字符动画,靠... */
     return result.babys;
}



[ Last edited by 523066680 on 2010-9-5 at 19:44 ]
作者: 523066680     时间: 2010-8-12 22:58


2i5HMABAA&&ABMMA9A&2hHhG39BBSrs29HM#B#BHA#M#B&A#GSX993X3G2:..
S5H#H 广州威立舜电子  XS239irisi5hAH##A#H#BM##ABB323333h&2:..
5GMAA =.=这是转换来的 S32irrSsXSXXX2&3AAMBA3H#MB#AX2X39395:..
53AHAHH#AMBM##BB#h2MhS2G9Srr5s99iX32Ss;r3AB#2iA#B##h2X33X2S,
9&BAHBM##B###MM#A3Mh5hA3555X9AHX5XXiSr,,,X##AiiHMH#B22XXX2i,
&HHABB###M##M###BM9XA&2SXGGB#Bh9hXSiS;...:&#A#23BBM#&22XG&3,
GH&G&MM###AM##AAM39Hh52&HB##&9GAA2iir... ,rMBAA3AM##Bh3hGAA:
GBA&&#MAAAAM#AAMGAA3SGMHA##9SAAhA5r;,.... ,5B#A9&M##HAhGh&A;
GB#MHHMAAA##AAHGBHAGM#AAHHi;XMS9hS:,.....  ,&BA#GH##AAABhAM;
GMAM#B#AAA#A#&AMM####HGAh;,rA5rAX,.. .,:;r;;XM#AA&M#A&HM&BAr
hMA#A#AA###H&#AAA###AS2i,.:X3,Xh, ,:s5Sir;::rH#A#GAABA#MBAAs
9B##AAAAMA&A#AAA##AB222sssrh:sG, ,;5i:.  .,,:3###A&BMBA#BAAi
9A##AAAMGA#AAAABHG;,:,,:rSSs:S, ,:;:,;h#A#Bhr2##MAABAA##H#A5
AAAM#BB##AAA#A#H2;:rrrr:::;;;,...,:;AAAAA,.#&XM#BAA####HHAAX.
#MMH#AA#AAABB#HX5AAAAAAB;;;::,....:;,hA2; .;;5AAB#ABMMA##AA9.
#AAAAAA#A###HhXXAMrBMAA, .::::,..     .. ,:,,;3AM#A#BB#M#AA&.
2AA#AAA#B#M#M3sriir;r;,.,,,,:::..            ,SAB###BBM&BAAA.
SGAAAAAAHM#MM9;;:,.   .,,,,,,::,....        . XABA##HBMGH#AA
25#AAAAAMBAM#Br::.    ...,,,,,:,..............A#BA##BM#&H#AM,
3XGAAAAAAMA#MA3;;,,,.....,,,,::,........,,,,.:A#BMA#B###M#A#.
h92AAAAAAA#AMHAi;::::,,,,,,,:;;r:;:.....,,,,.iA#MhH#####MMA#.
9hXXAA#AAAAA#&hir::::::::,,::;rss;:....,,,,,,HA#AAM99A#A##AH.
h&Xh#A#A#AAAAMBS;;:::::::::,,,:::,.  .,,:::.sAAB&MBhirr5MAA&
hG9AAAMM#AAAAAA#r:;;:::::::,:::,,,:iX,,:::,;AA#AHBHA9S:  rAH
&GhAAA#GMB&#AA#A#;,;;;;;;::rMHh99HM##:,::,rAAMMHHHH&i:. , :AM
HAAMAX#M9BHGAAA#AA5;:;;;;;;;iAAH2si5s..,,iAA##BAHAAG;  ,i,5#2
AHA5,rAABAMGAAAAAAAB2r;:;;;;,;ris,:i2i::&AA###HhM&9G;..r:r#2r
X2s:rHA#A#AB&A#AAAAAMBhi;;;;;:;riiS55AHG&B##B#&h#G3G2;;;;&2sX
;:;shABXHA#AHAA#AAM##AM#H3i;;;::,::;XMMA25i2##h#A&i2&;:;92ssA
;;iiiBBh&#A#GAH&M#BA#A23hGGh2ir;;;riSsri2XX2S29AAA;2&,:XA2hH2
;rirrABHH##AA&HAGA#GhHiiS552X33X222ir;;:29SX&2s2HBX&r,SMAGHA5
;;r;:G#AAMAAAA&H&AHH5HXsiiiiiiiiiis;;;rr5#A3S5hXi2Ai:XABA&&&X



[ Last edited by 523066680 on 2010-9-5 at 19:44 ]
作者: 523066680     时间: 2010-9-5 19:45    标题: [perl] 字符转 UTF-8 编码

偶然要用到,某个杂牌手机的T卡通讯录里面的字的储存使用UTF-8编码的
#!/usr/bin/perl
open READ,"<next.x";

$lv_[1]=00000000;
$lv_[2]=11000000;
$lv_[3]=11100000;
$lv_[4]=11110000;
$lv_[5]=11111000;
$lv_[6]=11111100;

use utf8;

$a="我";
printf "%s\n",&code2utf(ord $a);
print "END!";
<STDIN>;


sub code2utf {
my ($code,$bin,$level,$hex,$tmp,$result);
$code=$_[0];
$bin=sprintf "%b",$code;

$level=1;
if (length($bin)>7) {
  while (length($bin)>=6) {
     $level+=1;
     $bin=~s/.{6}$//;
     $hex=sprintf "%X",&bin2int(10 . $&);
     $result=$hex ."-". $result;
  }
}

$tmp=substr($lv_[$level],0,8-length($bin));
$hex=sprintf "%X",&bin2int($tmp . $bin);
$result=$hex ."-". $result;
$result=~s/-$//;  
$result;   #result - string
}

sub bin2int {
my ($a,$str,$all,$act);
$a=$_[0];
$str="";
$all=0;
$act=0;
do {
   $b=($a % 10) * (2**$act);  #** as ^ of the calc
   $all+=$b;
   $act+=1;
   $a=int ($a/10);
} until ($a==0);
int ($all);
}

作者: yaoyao1220     时间: 2010-11-2 15:57
看到脑袋晕了。。。
作者: cutebe     时间: 2014-4-7 20:29    标题: Re: 523066680编辑区



  Quote:
Originally posted by 523066680 at 2009-02-13  18:49:
@echo off &setlocal enabledelayedexpansion
set /p inp=" : "
call :funa na %inp%
call :funa nb %inp:* =%


set /a lpna=0,lpr=-1
:lpna
set /a lpna+=1,lpnb=0,lpr+=1,lp=lpr
  :lpnb
  set /a lpnb+=1,lp+=1
  ::::::::::::::::::::::::::
    set /a cup%lp%+=na%lpna%*nb%lpnb%
     set /a tlpa=lp,tlpb=tlpa+1
     :cuplp
     set /a cup%tlpb%+=cup%tlpa%/10,cup%tlpa%=cup%tlpa%%%10
     if !cup%tlpb%! gtr 9 (
        set /a tlpa+=1,tlpb=tlpa+1
        goto :cuplp
     ) else (if !cup%tlpb%! equ 0 set /a tlpb-=1)

  ::::::::::::::::::::::::::
  if %lpnb% lss %nb% (goto :lpnb)
if %lpna% lss %na% (goto :lpna)

for /l %%a in (%tlpb%,-1,1) do set /p=!cup%%a!<nul
echo,
echo,wscript.echo %inp: =*%>x.vbs
cscript //nologo x.vbs
pause>nul &exit


:funa
set %1=%2
set funaa=0
:funaa
  set /a funaa+=1
  set %1%funaa%=!%1:~-%funaa%,1!
if not "!%1:~%funaa%!"=="" (goto :funaa)
set /a %1=funaa
版本2
@echo off &setlocal enabledelayedexpansion
set /p inp=" : "
call :naxnb %inp%
pause

:naxnb
set numa=%1
set numb=%2
set /a la=0,lpr=-1
:la
set /a la+=1,lb=0,lpr+=1,lp=lpr
  :lb
  set /a lb+=1,lp+=1,tlpa=lp,tlpb=lp+1
  :::::::::::::::::::::::::
  set /a cup%lp%+=!numa:~-%la%,1! * !numb:~-%lb%,1!
     :cuplp
     set /a cup%tlpb%+=cup%tlpa%/10,cup%tlpa%=cup%tlpa%%%10
     if !cup%tlpb%! gtr 9 (
        set /a tlpa+=1,tlpb=tlpa+1
        goto :cuplp
     ) else (if !cup%tlpb%! equ 0 set /a tlpb-=1)
  ::::::::::::::::::::::::::
  if not "!numb:~%lb%!"=="" (goto :lb)
if not "!numa:~%la%!"=="" (goto :la)
for /l %%a in (%tlpb%,-1,1) do set /p=!cup%%a!<nul

::::::::vbs验证一下:::::::::::
echo,
echo,wscript.echo %inp: =*%>x.vbs
cscript //nologo x.vbs
pause>nul &exit
[ Last edited by 523066680 on 2009-2-21 at 10:46 ]

命令行模式测试:
真的可以加吗?
怎么退出?靠!
作者: 523066680     时间: 2015-6-13 14:42
咦还有人上来?
作者: yishanju     时间: 2015-10-14 14:50
哈哈,你不也还上来。
作者: 523066680     时间: 2016-7-6 20:14    标题: [Perl]批量下载高中物理必修选修电子课本(jpg


=info
    Edit: vicyang
    Mail: 523066680@163.com
    Date: 2016-06
=cut

use v5.16;
use utf8;
use Encode;
use LWP::UserAgent;
use LWP::Simple qw/getstore get/;
use IO::Handle;
STDOUT->autoflush(1);

our $website = "http://www.pep.com.cn/gzwl/jszx/tbjx/kb/dzkb/";
#our $website = "\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x70\x65\x70\x2E\x63\x6F\x6D\x2E\x63\x6E\x2F\x67\x7A\x77\x6C\x2F\x6A\x73\x7A\x78\x2F\x74\x62\x6A\x78\x2F\x6B\x62\x2F\x64\x7A\x6B\x62\x2F";

our $bookpage;
our $WORKDIR;
our $page1maps;
my  ($path, $begin, $end);

my @booklist = qw/
        bx1  bx2 xx11 xx12 xx21 xx22 xx23 xx31 xx32 xx33 xx34 xx35 /;


for my $book ( @booklist[0 .. $#booklist]  )
{
        print "Now is downloading: $book\n";
        $bookpage = $website. $book . "/";
        $WORKDIR  =  "D:\\Extra\\Book\\Physics\\" . $book;

        CreatePath($WORKDIR);

        ($path, $begin, $end) = get_pgnum_range( $bookpage );
        print "Path: $path, $begin to $end\n";

        #页面1 对应的 页码
        $page1maps = get_who_map_page1( $bookpage );

        get_picture( $bookpage, $path, $begin, $end );
}

system("pause");

sub get_pgnum_range
{
        my $bookpage = shift;
        my $all;
        $all = get($bookpage);   #使用lwp::simple 得到的是unicode,
                                 #使用lwp::UserAgent 得到的是GB2312
        my @pglist;
        my $path;

        $all =~s/.*封面//s;      #如果有封面,剔除

        #./201102/t20110217_1021412.htm
        for my $e ( split("\r?\n", $all)  )
        {
                if ($e=~/href="\.\/([^"]*_)(\d+).htm"/)
                {
                        $path = $1;
                        push @pglist, $2;
                }
        }

        @pglist = sort @pglist;
        return $path, @pglist[ 0, $#pglist ];
}

sub get_who_map_page1
{
        my $bookpage = shift;
        my $all = get($bookpage);

        $all=~s/\r?\n//g;
        if ( $all=~/\d+_(\d+)\.htm[^.]+第/ )
        {
                return $1;
        }
        else
        {
                die "first page code not found! ";
        }
}


sub get_picture
{
        my ($bookpage, $path, $begin, $end) = @_;

        our $page1maps;
        our $WORKDIR;
        my  $all;           #网页内容
        my  $subpage;       #子页面
        my  $pic;           #图片名
        my  $count = 0;     #页码计数
        my  $fname;         #文件名

        #该网页地址是逆序的,书本page+1,网址代码-1

        for (my $n = $end; $n >= $begin; $n-- )
        {
                $subpage = $bookpage . $path . $n . ".htm";

                $all = get( $subpage ) or next;
                if ( $all=~/IMG src="?\.\/([^".]*.jpg)"?/i )  #不一定有""符号
                {
                        $pic = $1;
                        $subpage =~s /[^\/]+$/$pic/;

                        if ( $n <= $page1maps )
                        {
                                $count++;
                                $fname = sprintf("%03d.jpg", $count);
                        }
                        else
                        {
                                $fname = $pic;
                        }

                        getstore($subpage, $WORKDIR."\\".$fname) or die "$!";
                        print "$pic\n";
                }
        }
}

sub CreatePath
{
    my $path = shift;
    my @arr=split(/[\\\/]/, $path);
    my $main;

    $main = shift @arr;  #以盘符开始

    for my $s (@arr)
    {
        $main .= "/" . $s;
        mkdir( $main ) if ( ! -d $main );
    }
}

作者: zzz19760225     时间: 2016-7-6 22:14
链接无效,占用了我一分,楼主还我。
作者: doslike     时间: 2016-7-26 14:52


  Quote:
Originally posted by zzz19760225 at 2016-7-6 22:14:
链接无效,占用了我一分,楼主还我。

论坛得以保住 实属不易。
数据丢失在所难免。
作者: 523066680     时间: 2016-9-28 11:43
其实是可以访问的,把域名部分改成现在的

http://www.cn-dos.net

改为

http://www.cn-dos.net
作者: zzz19760225     时间: 2016-9-28 13:19
以前是瞎子,没看到下面的编程语言,今天看到了,还你五分。
作者: zzz19760225     时间: 2017-12-4 13:49
路过