CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  VB.NET

请教问题,作业问题

楼主QooMc(可乐)2006-03-04 16:50:31 在 .NET技术 / VB.NET 提问

问题如下,小弟英文差,麻烦各位大哥帮帮忙!  
   
  1.  
  The   VB   function,   GetCurrencyCode   demonstrates   the   translation   between   the   currency   code   and   currency   number.     However,   the   performance   of   this   function   is   not   good   enough;   the   higher   order   of   input   number   takes   much   more   times   to   calculate.     Please   suggest   a   way   to   improve   the   program   performance:  
   
  Function   GetCurrencyCode(ByVal   input   As   String)   As   String  
      If   input   =   "01"   Then  
                    return   =   "AFA"  
      ElseIf   input   =   "02"   Then  
                    return   =   "ALL"  
      ElseIf   input   =   "03"   Then  
                    return   =   "DZD"  
      ElseIf   input   =   "04"   Then  
                    return   =   "USD"  
      ElseIf   input   =   "05"   Then  
                    return   =   "HKD"  
      ElseIf   input   =   "75"   Then  
                    return   =   "EUR"  
      ElseIf   input   =   "76"   Then  
                    return   =   "XCD"  
      ElseIf   input   =   "77"   Then  
                    return   =   "AMD"  
      End   If  
  End   Function  
   
   
  2.  
  Write   a   function   that   reverses   the   order   of   the   words   in   a   string.   For   instance,   your   function   should   transform   the   string   “Do   or   do   not,   there   is   no   try.”   To   “try.   No   is   there   not,   do   or   Do”.   Assume   that   all   words   are   space   delimited   and   treat   punctuation   the   same   as   letters.  
  Use   your   most   hands-on   programming   language.  
   
  3.  
  In   the   following   VB   program,   please   states   any   potential   problem(s)   and   how   to   correct.  
   
  Private   Sub   btnCalc_Click(   )  
                  Dim   result   As   Integer  
                        Try  
                                Me.Cursor   =   Windows.Forms.Cursors.WaitCursor  
                                result   =   Convert.ToInt32(txtInput1.Text)   /   Convert.ToInt32(txtInput2.Text)  
                                txtResult.Text   =   result  
                                Me.Cursor   =   Windows.Forms.Cursors.Default  
                        Catch   ex   As   Exception  
                                MsgBox(ex.StackTrace)  
                        Catch   ex   As   ArgumentNullException  
                                MsgBox("Input   Test   box   cannot   be   null.")  
                        Catch   ex   As   OverflowException  
                                MsgBox("Input   Test   box   2   cannot   be   zero!")  
                        Catch   ex   As   FormatException  
                                MsgBox("Input   Test   box   should   be   numeric   format!")  
                        End   Try  
  End   Sub  
   
   
  4.  
  Problem:   Use   your   most   hands-on   programming   language   to   implement   a   function   that   prints   all   possible   combinations   of   the   characters   in   a   string.   These   combinations   range   in   length   from   one   to   the   length   of   the   string.   Two   combinations   that   differ   only   in   ordering   of   the   characters   ARE   the   same   combination.     In   other   words,   “12”   and   “31”   are   different   combinations   from   the   input   string   “123”,   but   “21   is   the   same   as   “12”.  
   
  For   example,   if   we   use   “wxyz”   as   parameter   for   Combination(“wxyz”)   the   function   will   print   out  
   
  w  
  x  
  y  
  z  
  wx  
  wy  
  wz  
  xy  
  xz  
  yz  
  wxy  
  wxz  
  wyz  
  xyz  
  wxyz  
   
   
  5.  
  Module   modFree  
  #Region   "clsShape"  
  Public   Class   clsShape  
  Private   m_Area   As   Double  
  Private   m_Sides   As   Integer  
   
  Public   Sub   New()  
                m_Area   =   0.0  
                m_Sides   =   0  
  End   Sub  
   
  Public   Sub   New(ByVal   Sides   As   Integer)  
                m_Sides   =   Sides  
  End   Sub  
   
  Public   Sub   New(ByVal   Area   As   Double)  
                m_Area   =   Area  
  End   Sub  
   
  Public   Sub   New(ByVal   Area   As   Double,   ByVal   Sides   As   Integer)  
                m_Area   =   Area  
                m_Sides   =   Sides  
  End   Sub  
   
  Public   Property   Area()   As   Double  
          Get  
                  Return   m_Area  
          End   Get  
          Set(ByVal   Value   As   Double)  
                  m_Area   =   Value  
          End   Set  
  End   Property  
   
  Public   Property   Sides()   As   Integer  
          Get  
                  Return   m_Sides  
          End   Get  
          Set(ByVal   Value   As   Integer)  
                  m_Sides   =   Value  
          End   Set  
  End   Property  
  End   Class  
  #End   Region  
   
   
  #Region   "clsTriangle"  
  Public   Class   clsTriangle  
  Inherits   clsShape  
   
  Public   Sub   New()  
                  MyBase.New(3)  
  End   Sub  
   
  Public   Sub   New(ByVal   Area   As   Double)  
                  MyBase.New(Area,   3)  
  End   Sub  
   
  Public   Function   CalculateArea(ByVal   SideBase   As   Double,   ByVal   Height   As   Double,   _   Optional   ByVal   AssignToArea   As   Boolean   =   False)   As   Double  
          Dim   Area   As   Double   =   (SideBase   *   Height)   /   2  
   
          If   AssignToArea   Then  
                  Me.Area   =   Area  
          End   If  
   
          Return   Area  
  End   Function  
  End   Class  
  #End   Region  
   
  Public   Sub   Main()  
          Dim   objTriangle   As   New   clsTriangle  
          Dim   objShape   As   New   clsShape  
   
          objTriangle.Area   =   -330  
          objTriangle.Sides   =   5.5  
          objTriangle.CalculateArea(10.0,   2.5)  
   
          objShape.Area   =   123  
          objShape.Sides   =   -2  
          objShape   =   CType(objShape,   clsTriangle)  
   
          Console.WriteLine(TypeOf   objTriangle   Is   clsShape)  
          Console.WriteLine(TypeOf   objShape   Is   clsTriangle)  
          Console.WriteLine(objTriangle.Area)  
  End   Sub  
  End   Module  
   
  5.1   Please   find   the   line   of   code   from   the   procedure   Main   to   cause   run-time   error.  
   
  5.2   Please   write   the   result   output   from   the   procedure   Main.  
   
   
   
   
  问题点数:40、回复次数:7Top

1 楼hyena041(陷入自己的思维中,找不到自己了)回复于 2006-03-04 20:22:39 得分 0

考试题目阿  
  1大致上说的是下面给出的函数是做转换,并说明下面代码的效率并不高,让你来修改,提出改的方案  
        使用switch   case不要使用if   else  
  下面的没时间看了  
  呵呵,别人继续吧Top

2 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-04 21:21:23 得分 0

2.  
  Write   a   function   that   reverses   the   order   of   the   words   in   a   string.   For   instance,   your   function   should   transform   the   string   “Do   or   do   not,   there   is   no   try.”   To   “try.   No   is   there   not,   do   or   Do”.   Assume   that   all   words   are   space   delimited   and   treat   punctuation   the   same   as   letters.  
  Use   your   most   hands-on   programming   language.  
   
  使用你最拿手的语言写一个程序,程序的要求就是把一句话的语序到过来,比如:  
  “Do   or   do   not,   there   is   no   try.”   转换后就应该成为“try.   No   is   there   not,   do   or   Do”.   并且假定所有的单词之间通过空格进行分割并使用相同的标点符号Top

3 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-04 21:23:00 得分 0

3.  
  In   the   following   VB   program,   please   states   any   potential   problem(s)   and   how   to   correct.  
  找出下面程序中的任何可能存在的问题,并指出如何修正  
  Top

4 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-04 21:32:43 得分 0

4.  
  Problem:   Use   your   most   hands-on   programming   language   to   implement   a   function   that   prints   all   possible   combinations   of   the   characters   in   a   string.   These   combinations   range   in   length   from   one   to   the   length   of   the   string.   Two   combinations   that   differ   only   in   ordering   of   the   characters   ARE   the   same   combination.     In   other   words,   “12”   and   “31”   are   different   combinations   from   the   input   string   “123”,   but   “21   is   the   same   as   “12”.  
   
  For   example,   if   we   use   “wxyz”   as   parameter   for   Combination(“wxyz”)   the   function   will   print   out  
  问题:使用你最拿手的语言实现一个程序,打印出一个字符串中所有可能的字母组合。组合的范围是从字符串的第一个(字母)到最后一个(字母)。两个仅仅是字符顺序不同的组合作为相同的组合(来处理)。换句话说,“12”和“31”在字符串“123”中是不同的组合,但是“21”和“12”是相同的(组合)。  
  例如:假如我们使用“wxyz”作为参数传给组合函数的话,应该打印出。。。Top

5 楼terry1021_82(小狐狸)回复于 2006-03-04 21:48:42 得分 0

第2题,不知道这样写,行不?机子上没有装   VS   。调试不成。感觉可能在那三个符号上会抛异常  
   
  dim   a()   as   string=textbox1.text.split("   ")  
   
  array.reserve(a)  
   
  dim   b   as   string  
   
  for   i   as   integer=0   to   a.getupperbound(0)  
            b   &=   a(i)  
  next    
   
  textbox1.text=bTop

6 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-05 12:54:57 得分 0

TextBox2.text=""  
  for   i   as   integer   =   TextBox1.Text.Split("   ").Length   -1   to   0   step   -1  
      TextBox2.Text=TextBox1.Text.Split("   ")(i)   &   "   "  
  next   iTop

7 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-05 12:55:42 得分 0

忘了一个加号  
  TextBox2.text=""  
  for   i   as   integer   =   TextBox1.Text.Split("   ").Length   -1   to   0   step   -1  
      TextBox2.Text+=TextBox1.Text.Split("   ")(i)   &   "   "  
  next   i  
  Top

相关问题

  • 作业完成 :)
  • 不做作业
  • 作业问题
  • 概率作业
  • 杨过交作业
  • 长作业问题!
  • 作业题!求助!
  • 求作业答案
  • C程序作业
  • SQL作业失败

关键词

  • 组合
  • textbox
  • elseif input
  • 问题
  • split
  • then
  • integer
  • next
  • input
  • text

得分解答快速导航

  • 帖主:QooMc

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo