|
6622186
高级用户
   
积分 894
发帖 411
注册 2007-2-17
状态 离线
|
『第 106 楼』:
打印数字金字塔
使用 LLM 解释/回答一下
如题: 用批处理显示
1
121
12321
........................
12345678987654321
禁止全部使用 echo 命令.
As the title: Display with batch processing
1
121
12321
........................
12345678987654321
Prohibit using the echo command entirely.
|

@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul
|
|
2007-3-20 01:07 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 107 楼』:
使用 LLM 解释/回答一下
试下以下代码?
@echo off
setlocal enabledelayedexpansion
set "space= "
for /l %%i in (1 1 9) do (
for /l %%a in (1 1 %%i) do (
set str1=!str1!%%a
set str2=%%a!str2!
set str=%space%!str1!!str2:~1!
)
echo !str:~%%i!
set str1=
set str2=
set str=
)
pause>nul
Try the following code?
@echo off
setlocal enabledelayedexpansion
set "space= "
for /l %%i in (1 1 9) do (
for /l %%a in (1 1 %%i) do (
set str1=!str1!%%a
set str2=%%a!str2!
set str=%space%!str1!!str2:~1!
)
echo !str:~%%i!
set str1=
set str2=
set str=
)
pause>nul
|
|
2007-3-20 01:39 |
|
|
6622186
高级用户
   
积分 894
发帖 411
注册 2007-2-17
状态 离线
|
『第 108 楼』:
一共有多少苹果
使用 LLM 解释/回答一下
这是个很简单的数学题. 妈妈买回一篓苹果, 老大拿走了1/3, 老二拿走了剩下的1/3, 老三又拿走了剩下的1/3, 这时还剩 8 个苹果, 一共有多少苹果?
This is a very simple math problem. Mom bought a basket of apples. The eldest took 1/3, the second eldest took 1/3 of the remaining, the third one took 1/3 of the remaining. At this time, there are still 8 apples. How many apples are there in total?
|

@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul
|
|
2007-3-20 02:41 |
|
|
6622186
高级用户
   
积分 894
发帖 411
注册 2007-2-17
状态 离线
|
『第 109 楼』:
打印 N 阶矩阵.
使用 LLM 解释/回答一下
如题, N>=3, 可不用表格形显示. 如:
2 7 6
9 5 1
4 3 8
As the title says, N >= 3, no need to display in table form. For example:
2 7 6
9 5 1
4 3 8
|

@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul
|
|
2007-3-20 02:53 |
|
|
6622186
高级用户
   
积分 894
发帖 411
注册 2007-2-17
状态 离线
|
『第 110 楼』:
酷似百鸡问题
使用 LLM 解释/回答一下
1. 36块砖, 36人搬, 男搬4, 女搬3, 两个小孩抬块砖. 男人,女人和小孩各有多少人?
2. 百钱买百牛, 公牛3贯, 母牛4贯,小牛600文, 公牛,母牛和小牛各有多少头?(一贯=1000文)
### Problem 1
Let the number of men be \(x\), the number of women be \(y\), and the number of children be \(z\). Then we have the following system of equations:
\
Multiply equation \((2)\) by \(2\) to get rid of the fraction: \(8x + 6y + z = 72 \quad (3)\)
Subtract equation \((1)\) from equation \((3)\): \((8x + 6y + z) - (x + y + z) = 72 - 36\)
\(7x + 5y = 36\)
Since \(x\) and \(y\) are positive integers, we can try values for \(x\):
If \(x = 1\), then \(7\times1 + 5y = 36\), \(5y = 29\), \(y\) is not an integer.
If \(x = 2\), then \(7\times2 + 5y = 36\), \(14 + 5y = 36\), \(5y = 22\), \(y\) is not an integer.
If \(x = 3\), then \(7\times3 + 5y = 36\), \(21 + 5y = 36\), \(5y = 15\), \(y = 3\)
Substitute \(x = 3\) and \(y = 3\) into equation \((1)\): \(3 + 3 + z = 36\), \(z = 30\)
So there are 3 men, 3 women, and 30 children.
### Problem 2
Let the number of bullocks be \(x\), the number of cows be \(y\), and the number of calves be \(z\). Then we have:
\
Simplify equation \((2)\) by dividing by 100: \(30x + 40y + 6z = 1000\), further divide by 2: \(15x + 20y + 3z = 500 \quad (3)\)
Multiply equation \((1)\) by 3: \(3x + 3y + 3z = 300 \quad (4)\)
Subtract equation \((4)\) from equation \((3)\): \((15x + 20y + 3z) - (3x + 3y + 3z) = 500 - 300\)
\(12x + 17y = 200\)
Solve for \(x\): \(x = \frac{200 - 17y}{12}\)
Since \(x\) and \(y\) are positive integers, we try values for \(y\):
If \(y = 4\), then \(x = \frac{200 - 17\times4}{12} = \frac{200 - 68}{12} = \frac{132}{12} = 11\)
Substitute \(x = 11\) and \(y = 4\) into equation \((1)\): \(11 + 4 + z = 100\), \(z = 85\)
So there are 11 bullocks, 4 cows, and 85 calves.
|

@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul
|
|
2007-3-20 03:08 |
|
|
6622186
高级用户
   
积分 894
发帖 411
注册 2007-2-17
状态 离线
|
『第 111 楼』:
古代问题(九章算术,七, 盈不足), 求人数和羊价.
使用 LLM 解释/回答一下
有一群人一起买羊, 若每人出 5 两, 还差 45 两, 若每人出 七 两, 还差 3 两, 问有多少买羊, 羊的价钱是多少.
There is a group of people buying sheep together. If each person pays 5 taels, there is still a shortage of 45 taels. If each person pays 7 taels, there is still a shortage of 3 taels. Ask how many people are buying sheep and how much the sheep costs.
|

@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul
|
|
2007-3-20 03:52 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 112 楼』:
使用 LLM 解释/回答一下
Originally posted by 6622186 at 2007-3-20 02:41 AM:
这是个很简单的数学题. 妈妈买回一篓苹果, 老大拿走了1/3, 老二拿走了剩下的1/3, 老三又拿走了剩下的1/3, 这时还剩 8 个苹果, 一共有多少苹果?
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1 1 10000) do (
title 正在检测 %%i ....
set /a tmp=%%i*8/27
if !tmp! EQU 8 echo %%i && goto :exit
)
:exit
pause>nul
其实,以上的代码还可以简单的(根据数学原理),简单到不好意思(没什么代码可以写了。)
Originally posted by 6622186 at 2007-3-20 02:41 AM:
This is a very simple math problem. Mother bought a basket of apples. The eldest took 1/3, the second took 1/3 of the remaining, the third took 1/3 of the remaining, and there were 8 apples left. How many apples were there in total?
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1 1 10000) do (
title Checking %%i....
set /a tmp=%%i*8/27
if !tmp! EQU 8 echo %%i && goto :exit
)
:exit
pause>nul
Actually, the above code can be simpler (according to mathematical principles), so simple that it's embarrassing (there's not much code to write).
|
|
2007-3-20 04:54 |
|
|
6622186
高级用户
   
积分 894
发帖 411
注册 2007-2-17
状态 离线
|
『第 113 楼』:
使用 LLM 解释/回答一下
这样就可以计算大于2^31 的数字, 我以为不可能, 不过代码不太懂. 看到 ! 就头疼.
This way, you can calculate numbers greater than 2^31. I thought it was impossible, but I don't understand the code. Seeing! gives me a headache.
|

@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul
|
|
2007-3-20 11:34 |
|
|
scriptor
银牌会员
    
积分 1187
发帖 555
注册 2006-12-21
状态 离线
|
『第 114 楼』:
使用 LLM 解释/回答一下
112楼
你是不是先算了再写成这样的?
你的那句"set/a tem=%%i*8/27&np if !temp! equ 8 echo %%i....." 不就是说%%i是27 吗?
那还算什么?
112th floor
Did you first calculate it and then write it like this?
Your sentence "set/a tem=%%i*8/27&np if !temp! equ 8 echo %%i....." doesn't it mean that %%i is 27?
Then what are you calculating?
|
|
2007-3-20 18:29 |
|
|
scriptor
银牌会员
    
积分 1187
发帖 555
注册 2006-12-21
状态 离线
|
『第 115 楼』:
使用 LLM 解释/回答一下
完整的解法是这样的:
设共有Y。
第一次取了它的1/3, 留了2/3*Y;
第二次又取了剩下的1/3,就留了2/3*(2/3*Y);
第三次再取第二次取后剩下的1/3,只留下2/3*(2/3*(2/3*Y)).
hehe
这就是说:2/3*(2/3*(2/3*Y))=8
那么Y就是27。
The complete solution is as follows:
Let the total be Y.
The first time, 1/3 of it is taken, leaving 2/3 * Y;
The second time, 1/3 of the remaining is taken again, leaving 2/3 * (2/3 * Y);
The third time, 1/3 of the remaining after the second time is taken, leaving only 2/3 * (2/3 * (2/3 * Y)).
hehe
This means: 2/3 * (2/3 * (2/3 * Y)) = 8
Then Y is 27.
|
|
2007-3-20 18:38 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 116 楼』:
使用 LLM 解释/回答一下
Originally posted by scriptor at 2007-3-20 06:29 PM:
112楼
你是不是先算了再写成这样的?
你的那句"set/a tem=%%i*8/27&np if !temp! equ 8 echo %%i....." 不就是说%%i是27 吗?
那还算什么?
如果说,要完全模拟用程序来解决的话,似乎更简单.根据题目的意思,这个数一定是27的倍数(它可以连续被3除3次).所以代码可以写成:
for /l %%i (27 27 100000) do (
....)
似乎是更简单了,一下就可以得出是 27.
Originally posted by scriptor at 2007-3-20 06:29 PM:
Post 112
Did you calculate first and then write it like this?
Your sentence "set/a tem=%%i*8/27&np if !temp! equ 8 echo %%i....." means that %%i is 27?
Then what are you calculating?
If we say, to completely simulate solving it with a program, it seems simpler. According to the meaning of the problem, this number must be a multiple of 27 (it can be continuously divided by 3 three times). So the code can be written as:
for /l %%i (27 27 100000) do (
....)
It seems simpler, and you can get 27 at once.
|
|
2007-3-20 22:21 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 117 楼』:
使用 LLM 解释/回答一下
Originally posted by 6622186 at 2007-3-19 12:07:
如题: 用批处理显示
1
121
12321
........................
12345678987654321
禁止全部使用 echo 命令.
临走前跟个代码帖:
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1,1,9) do (
for /l %%j in (9,-1,%%i) do set /p= <nul
for /l %%k in (1,1,%%i) do set /p=%%k<nul
set /a num=%%i-1
for /l %%l in (!num!,-1,1) do set /p=%%l<nul
echo.
)
pause
Originally posted by 6622186 at 2007-3-19 12:07:
As the title says: Display using batch processing
1
121
12321
........................
12345678987654321
Prohibit the use of all echo commands.
Before leaving, post a code:
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1,1,9) do (
for /l %%j in (9,-1,%%i) do set /p= <nul
for /l %%k in (1,1,%%i) do set /p=%%k<nul
set /a num=%%i-1
for /l %%l in (!num!,-1,1) do set /p=%%l<nul
echo.
)
pause
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2007-3-21 02:29 |
|
|
dbslong
新手上路

积分 5
发帖 3
注册 2007-6-13
状态 离线
|
『第 118 楼』:
#25题,小鸡21只,小狗58,“借花献佛“
使用 LLM 解释/回答一下
@echo off
echo.
echo 小鸡、小狗七十九,二百只脚在地上走,想一想,算一算,多少只鸡?多少只狗?
echo.
setlocal enabledelayedexpansion
set /a x=79
set /a y=200
for /l %%i in (1,1,79) do (
for /l %%j in (1,1,50) do (
set /a a=2*%%i
set /a b=4*%%j
set /a sum1=%%i+%%j
set /a sum2=!a!+!b!
if !sum1! equ !x! if !sum2! equ !y! echo %%i %%j
)
)
pause
@echo off
echo.
Chickens and dogs total 79, with 200 feet on the ground. Think and calculate, how many chickens? How many dogs?
echo.
setlocal enabledelayedexpansion
set /a x=79
set /a y=200
for /l %%i in (1,1,79) do (
for /l %%j in (1,1,50) do (
set /a a=2*%%i
set /a b=4*%%j
set /a sum1=%%i+%%j
set /a sum2=!a!+!b!
if !sum1! equ !x! if !sum2! equ !y! echo %%i %%j
)
)
pause
|
|
2007-6-13 23:17 |
|
|
dbslong
新手上路

积分 5
发帖 3
注册 2007-6-13
状态 离线
|
『第 119 楼』:
第26# 大和尚20小和尚80
使用 LLM 解释/回答一下
@echo off
echo.
echo 百个和尚百个粑,大和尚每人粑四个,小和尚四人一个粑,大、小和尚各有几?
echo.
setlocal enabledelayedexpansion
set /a x=100
for /l %%i in (1,1,25) do (
for /l %%j in (1,1,100) do (
set /a a=4*%%i
set /a b=%%j/4
set /a sum1=%%i+%%j
set /a sum2=!a!+!b!
if !sum1! equ !x! if !sum2! equ !x! echo "大和尚" %%i "小和尚" %%j
)
)
pause
@echo off
echo.
One hundred monks and one hundred pastries. Each big monk gets four pastries, and four little monks share one pastry. How many big and little monks are there respectively?
echo.
setlocal enabledelayedexpansion
set /a x=100
for /l %%i in (1,1,25) do (
for /l %%j in (1,1,100) do (
set /a a=4*%%i
set /a b=%%j/4
set /a sum1=%%i+%%j
set /a sum2=!a!+!b!
if !sum1! equ !x! if !sum2! equ !x! echo "Big monk" %%i "Little monk" %%j
)
)
pause
|
|
2007-6-13 23:28 |
|
|
lwgea
新手上路

积分 4
发帖 2
注册 2006-11-27
状态 离线
|
|
2007-6-27 16:15 |
|
|