主题:6题
301梯子梯子
[专家分:0] 发布于 2010-10-25 19:43:00
1.设三段线段长度分别为a、b、c,且a>=b>=c>0,写一个程序,判别给出a、b、c能否组成一个三角型?
2.将字符A,B,C,D或a,b,c,d转换成1,2,3,4,其余的转成5。
3.求N个整数的最大公约数和最小公倍数。
4.猴子吃枣问题。猴子摘了一堆枣,第一天吃了一半,还嫌不过瘾,又吃了一个;第二天又吃了剩下的一半零一个;以后每天如此。到第十天,猴子一看只剩下一个了。问最初有多少个枣子?
5.任给一个自然数n,求出这个自然数不同因数的个数。例如 n=6时,因为1,2,3,6这四个数均是6的因数,故输出为total=4
6、打印一万以内的完全数(亲和数),完全数定义:一个数的因子和等于这个数本身的那么这个数就称作为完全数,例6的因子和1+2+3=6则6为完全数。(此题目的因子和都不包括本身这个因子)
全部要文本格式
最后更新于:2010-10-25 19:45:00
回复列表 (共13个回复)
沙发
幽灵密码 [专家分:3510] 发布于 2010-10-25 19:49:00
OPEN "1.in" FOR INPUT AS #1
OPEN "1.out" FOR OUTPUT AS #2
INPUT #1, a, b, c
IF a < b THEN SWAP a, b
IF a < c THEN SWAP a, c
IF b < c THEN SWAP b, c
IF b + c > a THEN PRINT #2, "YES" ELSE PRINT #2, "NO"
CLOSE
END
板凳
verysmartboy [专家分:1260] 发布于 2010-10-25 19:57:00
1.cls
input a,b,c
a(1)=a
a(2)=b
a(3)=c
for i=1 to 2
for j=i+1 to 3
if a(i)>a(j) then swap a(i),a(j)
next j
next i
if (a(1)+a(2))>a(3) then print "yes" else print "no"
end
3 楼
幽灵密码 [专家分:3510] 发布于 2010-10-25 20:00:00
OPEN "1.in" FOR INPUT AS #1
OPEN "1.out" FOR OUTPUT AS #2
INPUT #1, a$
FOR i = 1 TO LEN(a$)
b$ = MID$(a$, i, i1)
SELECT CASE ASC(b$)
CASE IS = 65 OR 97
PRINT "1";
CASE IS = 66 OR 98
PRINT "2";
CASE IS = 67 OR 99
PRINT "3";
CASE IS = 68 OR 100
PRINT "4";
CASE ELSE
PRINT "5";
END SELECT
NEXT i
CLOSE
END
4 楼
幽灵密码 [专家分:3510] 发布于 2010-10-25 20:00:00
那是2
5 楼
verysmartboy [专家分:1260] 发布于 2010-10-25 20:02:00
4.cls
n=1
for i=9 to 1 step-1
n=(n+1)*2
next i
print n
end
6 楼
verysmartboy [专家分:1260] 发布于 2010-10-25 20:03:00
2.CLS
OPEN "1.IN" FOR INPUT AS #1
OPEN "1.OUT" FOR OUTPUT AS #2
INPUT #1,a$
FOR i = 1 TO LEN(a$)
b$ = MID$(a$, i, i1)
SELECT CASE ASC(b$)
CASE IS = "A"OR "a"
PRINT "1";
CASE IS = "B" OR "b"
PRINT "2";
CASE IS = "C" OR "c"
PRINT "3";
CASE IS = "D" OR "d"
PRINT "4";
CASE ELSE
PRINT "5";
END SELECT
NEXT i
CLOSE
END
7 楼
verysmartboy [专家分:1260] 发布于 2010-10-25 20:05:00
5.cls
input n
total=0
for i=1 to n
if n mod i=0 then total=total+1
next i
print total
end
8 楼
301梯子梯子 [专家分:0] 发布于 2010-10-25 20:07:00
OPEN "1.in" FOR INPUT AS #1
OPEN "1.out" FOR OUTPUT AS #2
INPUT #1, n
DIM a(n)
INPUT #1, a(1): min = a(1)
FOR i = 2 TO n
INPUT a(i): IF a(i) < min THEN min = a(i)
NEXT i
FOR i = min TO 1 STEP -1
FOR j = 1 TO n
IF a(j) MOD i = 0 THEN f = f + 1
NEXT j
IF f = n THEN p = i: PRINT #2, i: GOTO 10000000
f = 0
NEXT i
10000000 FOR i = 1 TO n
x = x * i: x = x / p
NEXT i
PRINT #2, x
CLOSE
END
9 楼
verysmartboy [专家分:1260] 发布于 2010-10-25 20:12:00
cls
open "1.in" for input as #1
open "1.out" for output as #2
for i=1 to 10000
n=0
for j=1 to i
if i mod j=0 then n=n+j
next j
if i=n then print #2,i
next i
close
end
10 楼
幽灵密码 [专家分:3510] 发布于 2010-10-25 20:19:00
3.
OPEN "1.in" FOR INPUT AS #1
OPEN "1.out" FOR OUTPUT AS #2
INPUT #1, n
DIM a(n)
INPUT #1, a(1): min = a(1)
FOR i = 2 TO n
INPUT a(i): IF a(i) < min THEN min = a(i)
NEXT i
FOR i = min TO 1 STEP -1
FOR j = 1 TO n
IF a(j) MOD i = 0 THEN f = f + 1
NEXT j
IF f = n THEN p = i: PRINT #2, i: GOTO 10000000
f = 0
NEXT i
10000000 FOR i = 1 TO n
x = x * i: x = x / p
NEXT i
PRINT #2, x
CLOSE
END
我来回复