1. 求园的面积(要求判断半径是否合理)
Clea
Inpu ‘r=’ to r
If r>0
S=3.14*r*r
?s
Else
?’半径错误!’
Endif
2. 求分段函数Y 的值
Clea Inpu ‘x=’If x>0
Y=2*x+5
Else
If x=0
Y=x
Else
Y=abs(x)
Endif
Endif
?y
3. 输入一个百分制成绩判断其等级(优/良/中/及格/不及格)
Clea
Inpu ‘cj=’ to cj
Do case
Case cj>=90
?’优’
Case cj>=80
?’良’
Case cj>=70
?’中’
Case cj>=60
?’及格’
Orth
?’不及格’
Endcase
4. 输入若干个(个数不定)百分制成绩判断其等级(优/良/中/及格/不及格)
Clea
Inpu ‘请输入处理几个人的成绩:’ to n
For i=1 to n
Inpu ‘cj=’ to cj
Do case
2x +5 x>0 x x=0 | x | x<0
Case cj>=90
?’优’
Case cj>=80
?’良’
Case cj>=70
?’中’
Case cj>=60
?’及格’
Orth
?’不及格’
Endcase
endfor
5.求S=1+2+3. . . . . .+100
C
lea
S=0
For i=1 to 100
S=s+i
Endfor
?s
6.求S=1×2×3. . . . . .×100
Clea
p=1
For i=1 to 100
p=p*i
Endfor
?p
7.求S=1+3+5.. . . . .+99
Clea
S=0
For i=1 to 99 step 2
S=s+i
Endfor
?s
8.求S=1-2+3-4. . . . . .-100
Clea
S=0
For i=1 to 100
S=s+(-1)^(i+1)*i
Endfor
?s
9.求S=1+1/2+2/3+3/5. . . . . .前10项之和Clea
S=0
A=1
B=1
For i=1 to 10
S=s+a/b
T=a
A=b
B=t+b
Endfor
?s
10. 求S =1!+2!+3!. . . . . .+10!
Clea
S=0
P=1
For i=1 to 10
P=p*i
S=s+p
Endfor
?s
11. 对学生表中所有入学成绩≥650分的学生免去贷款
Clea
Use 学生
Scan for 入学成绩>=650 .and. 贷款否=.t.
Repl 贷款否 with .f.
Endscan
Use
12. 输出图形
Clea For i=1 to 4
For j=1 to i
??’*’
Endfor
?
Endfor
Clea
For i=1 to 4
For j=1 to 4-i
??’ ’ &&有一个空格
Endfor
For j=1 to 2*i-1
??’*’
* **** * *******
* **** ** *** *** *****
** *** *** ** ***** ***
*** ** **** * ******* *
**** *
?
Endfor
Clea
For i=1 to 4
For j=1 to 4-i
??’’&&有一个空格Endfor
For j=1 to i
??’*’
Endfor
?
Endfor
13.判断一个整数是否素数Clea
Inpu ‘x=’ to x
For i=2 to x-1
If mod(x,i)<>0
Loop
Else
Exit
Endif
Endfor
If i>x-1
?x,’是素数’
Else
?x,’不是素数’
Endif
14.判断十个整数是否素数Clea
For j=1 to 10
Inpu ‘x=’ to x
For i=2 to x-1
If mod(x,i)<>0
Loop
Else
Exit
Endif
Endfor
If i>x-1
?x,’是素数’
Else
?x,’不是素数’
Endif
15.找出两个数的大数和小数Clea
Inpu ‘x=’ to x
Inpu ‘y’to y
If x>y
?x,’大’,y,’小’
Else
?y,’大’,x,’小’
Endif
16.找出三个数的最大数和最小数Clea
Inpu ‘x=’ to x
Inpu ‘y’to y
Inpu ‘z’to z
If x t=x x=y y=t Else If x t=x x=z z=t endif endif if y t=y y=z z=t endif ?x,’是最大数’,z,’是最小数’ 17.找出十个数的最大数和最小数Clea Dime a(10) For i=1 to 10 Inpu to a(i) Endfor Max=a(1) Min=a(1) For i=2 to 10 If max Max=a(i) Else If min>a(i) . Min=a(i) Endif Endif Endfor ?max,min 18.找出2×3矩阵中的最大数和最小数 clea dime a(2,3) for i=1 to 2 for j=1 to 3 input ‘a(‘+str(I,2)+’,’+str(j,2)+’)=’to a(I,j) endfor endfor max=a(1,1) min=a(1,1) for i=1 to 2 for j=1 to 3 if max max= a(I,j) else if min> a(I,j) min= a(I,j) endif endif endfor endfor ?’max=’,max,’min=’,min 19.对三个整数从大到小排序 Clear Input ‘a=’ to a Input ‘b=’ to b Input ‘c=’ to c If a T=a A=b B=t Else If a t=a A=c c=t endif endif If b T=b A=c c=t endif ?a,b,c 20.对十个整数从大到小排序(用选择法和起泡法两种方法)选择法: Clear Dime a(10) For i=1 to 10 Input to a(i) Endfor For i=1 to 9 Max=a(i) Num=i For j=i+1 to 10 If max max=a(j) Num=j Endif Endfor If i<>num t=A(i) a(i)=a(num) a(num)=t Endif Endfor For i=1 to 10 ??a(i),' ' Endfor 起泡法: Clear Dime a(10) For i=1 to 10 Input to a(i) Endfor For i=1 to 9 For j=1 to 10-i