回 帖 发 新 帖 刷新版面

主题:问一下这道题 能解么?

1、第一个答案是b的问题是哪一个?   
  (a)2;(b) 3;(c)4;(d)5;(e)6  
2、唯一的连续两个具有相同答案的问题是:  
  (a)2,3;(b)3,4;(c)4,5;(d)5,6;(e)6,7;  
3、本问题答案和哪一个问题的答案相同?  
  (a)1;(b)2;(c)4;(d)7;(e)6  
4、答案是a的问题的个数是:             
  (a)0;(b)1;(c)2;(d)3;(e)4  
5、本问题答案和哪一个问题的答案相同? 
  (a)10;(b)9;(c)8;(d)7;(e)6  
6、答案是a的问题的个数和答案是什么的问题的个数相同? 
  (a)b;(b)c;(c)d;(d)e;(e)以上都不是 
7、按照字母顺序,本问题的答案和下一个问题的答案相差几个字母?   
  (a)4;(b)3;(c)2;(d)1;(e)0。(注:a和b相差一个字母)  
8、答案是元音字母的问题的个数是: 
  (a)2;(b)3;(c)4;(d)5;(e)6。(注:a和e是元音字母)  
9、答案是辅音字母的问题的个数是: 
  (a)一个质数;(b)一个阶乘数;(c)一个平方数;(d)一个立方数,(e)5的倍数  
10、本问题的答案是:  
  (a)a;(b)b;(c)c;(d)d;(e)e。 
  
 

回复列表 (共7个回复)

沙发

难道没有人会解么?我有个朋友的朋友 用 C  解出来了
  不知道 用 QB能解出来么??

板凳

好像有点浪费时间.没有什么实际意义.

3 楼

真的是很浪费时间,
但,
谁叫我那么无聊呢。

declare function tj2! ()
declare function tj3! ()
declare function tj4! ()
declare function tj5! ()
declare function tj6! ()
declare function tj7! ()
declare function tj8! ()
declare function tj9! ()
declare function tj10! ()
declare function nexta$ ()
dim shared a$
a$ = "aaaaaaaaaa"

do
  locate , 1: print a$,
  if instr(a$, "b") = asc(a$) - 95 and tj2 and tj3 and tj4 and tj5 and tj6 and tj7 and tj8 and tj9 and tj10 then print a$
  a$ = nexta$
loop until a$ = "aaaaaaaaaa"

function nexta$
l = len(a$)
do while l > 0
   select case mid$(a$, l, 1)
   case "a" to "d"
        mid$(a$, l, 1) = chr$(asc(mid$(a$, l, 1)) + 1)
        exit do
   case "e"
        mid$(a$, l, 1) = "a"
        l = l - 1
   case else
        exit do
   end select
loop
nexta$ = a$
end function

function tj10
tj10 = -1
end function

function tj2
     for i = 1 to len(a$) - 1
         if mid$(a$, i, 1) = mid$(a$, i + 1, 1) then
            same = same + 1
            if same > 1 then
               tj2 = 0
               exit for
            end if
            if i = asc(mid$(a$, 2, 1)) - 95 then tj2 = -1
         end if
     next
end function

function tj3
  if mid$(a$, val(mid$("12476", asc(mid$(a$, 3, 1)) - 96, 1)), 1) = mid$(a$, 3, 1) then tj3 = -1
end function

function tj4
for i = 1 to len(a$)
    if mid$(a$, i, 1) = "a" then n = n + 1
next
if n = asc(mid$(a$, 4, 1)) - 97 then tj4 = -1
end function

function tj5
  if mid$(a$, 11 - (asc(mid$(a$, 5, 1)) - 96), 1) = mid$(a$, 5, 1) then tj5 = -1
end function

function tj6
dim n(5)
for i = 1 to len(a$)
    b = asc(mid$(a$, i, 1)) - 97
    n(b) = n(b) + 1
next
n(5) = n(0)
s = asc(mid$(a$, 6, 1)) - 96
if n(0) <> n(s) then exit function
if s = 5 then
  for i = 1 to 4
   if n(i) = n(0) then exit function
  next
end if
tj6 = -1
end function

function tj7
s7 = asc(mid$(a$, 7, 1)) - 96
s8 = asc(mid$(a$, 8, 1)) - 96
if abs(s7 - s8) = 5 - s7 then tj7 = -1
end function

function tj8
for i = 1 to len(a$)
    if instr("ae", mid$(a$, i, 1)) > 0 then y = y + 1
next
if y = asc(mid$(a$, 8, 1)) - 95 then tj8 = -1
end function

function tj9
for i = 1 to len(a$)
    if instr("bcd", mid$(a$, i, 1)) > 0 then y = y + 1
next
s$ = chr$(y + 48)

select case asc(mid$(a$, 9, 1)) - 96
case 1: x$ = "2357"
case 2: x$ = "126"
case 3: x$ = "0149"
case 4: x$ = "018"
case 5: x$ = "05:"
end select
if instr(x$, s$) > 0 then tj9 = -1
end function

这是标准程序,
标准的意思是站在编程的角度去写。
速度非常的慢,我的电脑更慢,
加上我把所有的 IF 条件写在同一行了,更离谱,
一个多小时吧。

4 楼

是不是看得眼睛都花了?
这还不算,
站在效率的角度来看,
还可以加快速度的,
这个时候,更花的来了,
别怪我写得太难看,
只怨我过份追求效率和速度了。
现在,
不会再有人说 QB 解不出来 C 能解出来的东西了吧 ??
我想应该能在一分钟内解出结果,应该不会比 C 慢了吧??

5 楼

defint a-z
declare function nexta$ (ls%)
dim shared a$
dim tj6(5),x$(5)
sl=10
sa$=string$(sl,"a")
a$=sa$
x$(1)="2357"
x$(2)="126"
x$(3)="0149"
x$(4)="018"
x$(5)="05:"
do
  tj1=instr(a$,"b")
  tj12=asc(a$)-95
  if tj1=tj12 then
   same=0
   tj2=asc(mid$(a$,2,1))-95
   if mid$(a$,tj2,1)<>mid$(a$,tj2+1,1)then
    if mid$(a$,tj2+1,1)<mid$(a$,tj2,1)then
     mid$(a$,tj2+1,1)=mid$(a$,tj2,1)
     if tj2+1<sl then mid$(a$,tj2+2)=sa$
    else
     a$=nexta$(tj2)
    end if
   else
    for i=1 to sl-1
     if i<>tj2 then
      if mid$(a$,i,1)=mid$(a$,i+1,1) then exit for
     end if
    next
    if i=sl then
     tj3=asc(mid$(a$,3,1))-96
     tj32=val(mid$("12476",tj3,1))
     if mid$(a$,tj32,1)=mid$(a$,3,1)then
      tj4=0
      for i=1 to sl
       if mid$(a$,i,1)="a"then tj4=tj4+1
      next
      if tj4=asc(mid$(a$,4,1))-97 then
       tj5=11-(asc(mid$(a$,5,1))-96)
       if mid$(a$,tj5,1)=mid$(a$,5,1)then
        for i=0 to 5
         tj6(i)=0
        next
        for i=1 to len(a$)
         b=asc(mid$(a$,i,1))-97
         tj6(b)=tj6(b)+1
        next
        tj6(5)=tj6(0)
        s=asc(mid$(a$,6,1))-96
        if tj6(0)<>tj6(s)then
         a$=nexta$(sl)
        else
         if s=5 then
          for j=1 to 4
           if tj6(j)=tj6(0)then exit for
          next
         end if
         if s<>5 or j>4 then
          s7=asc(mid$(a$,7,1))-96
          s8=asc(mid$(a$,8,1))-96
          if abs(s7-s8)=5-s7 then
           tj8=0
           for i=1 to sl
            if instr("ae",mid$(a$,i,1))>0 then tj8=tj8+1
           next
           if tj8=asc(mid$(a$,8,1))-95 then
            tj9=sl-tj8
            if instr(x$(asc(mid$(a$,9,1))-96),chr$(tj9+48))>0 then print a$
           end if
            a$=nexta$(sl)
          else
           a$=nexta$(8)
          end if
         else
          a$=nexta$(sl)
         end if
        end if
       else
        a$=nexta$(tj5)
       end if
      else
       a$=nexta$(sl)
      end if
     else
      if tj32<3 then a$=nexta$(3)else a$=nexta$(tj32)
     end if
    else
     a$=nexta$(i+1)
    end if
   end if
  else
   if tj1=0 then
    a$=nexta$(sl)
   elseif tj1<tj12 then
    a$=nexta$(tj1)
   else
    a$=nexta$(tj12)
   end if
  end if
loop until a$=sa$

defsng a-z
function nexta$(ls%)
l%=ls%
if l%<len(a$) then mid$(a$,l%+1)=string$(10,"a")
do while l%>0
  select case mid$(a$,l%,1)
  case "a"to"d"
   mid$(a$,l%,1)=chr$(asc(mid$(a$,l%,1))+1)
   exit do
  case "e"
   mid$(a$,l%,1)="a"
   l%=l%-1
  case else
   end
  end select
loop
nexta$=a$
end function

6 楼

能 给出答案么???

7 楼

cdebeedcba

我来回复

您尚未登录,请登录后再回复。点此登录或注册