下载频道  >  mysteryflower的资源
  • 练习使用Java基本数据类型。使用Java的String类操作字符串和子串

    实验目的: 练习使用Java基本数据类型。使用Java的String类操作字符串和子串。 实验内容: 1.写一个程序提示用户键入某一货币数量(以分为单位),该程序应计算出如何用最少量的1元,50分,10分和1分硬币得到该数目。如195分最少可以用一个1元硬币,1个50分硬币,4个10分硬币和5个1分硬币组成。 注意不要用数组存放不同硬币的值。 2.写一个程序可以对两个字符串进行测试,得知第一个字符串是否包含在第二个字符串中。如字符串”PEN”包含在字符串“INDEPENDENT”中。 可以利用字符串类方法 boolean regionMatches(int toffset, String other, int ooffset, int len) toffset 指从被调用方法的字符串的第几个字符开始测试,如果是0,表明从字符串的首字符开始。other是指使用的另一个字符串。ooffset指从另一个字符串的第几个字符开始。len指要比较几个字符。该方法返回boolean值。 在本题中,ooffset为0,因为我们要测试整个短字符串;len是短字符串的长度;所以应该用 big.regionMatches(index, small, 0, small.length()) 如果big指“independent",small指"pen",则index=2时为假,index=4时为真 (b)改进程序,当第一个字符串包含在第二个字符串中时,显示第一个字符串在第二个字符串中的起始位置。 (c)改进程序,即使当用户输入顺序错误时(第一个是长字符串,第二个是短字符串),能自动在长字符串中搜寻短字符串。

    2010-06-25
    10
  • 用VC|MFC编写的计算器

    用VC|MFC编写的计算器,======================================================================== MICROSOFT FOUNDATION CLASS LIBRARY : counter ======================================================================== AppWizard has created this counter application for you. This application not only demonstrates the basics of using the Microsoft Foundation classes but is also a starting point for writing your application. This file contains a summary of what you will find in each of the files that make up your counter application. counter.dsp This file (the project file) contains information at the project level and is used to build a single project or subproject. Other users can share the project (.dsp) file, but they should export the makefiles locally. counter.h This is the main header file for the application. It includes other project specific headers (including Resource.h) and declares the CCounterApp application class. counter.cpp This is the main application source file that contains the application class CCounterApp. counter.rc This is a listing of all of the Microsoft Windows resources that the program uses. It includes the icons, bitmaps, and cursors that are stored in the RES subdirectory. This file can be directly edited in Microsoft Visual C++. counter.clw This file contains information used by ClassWizard to edit existing classes or add new classes. ClassWizard also uses this file to store information needed to create and edit message maps and dialog data maps and to create prototype member functions. res\counter.ico This is an icon file, which is used as the application's icon. This icon is included by the main resource file counter.rc. res\counter.rc2 This file contains resources that are not edited by Microsoft Visual C++. You should place all resources not editable by the resource editor in this file. ///////////////////////////////////////////////////////////////////////////// AppWizard creates one dialog class: counterDlg.h, counterDlg.cpp - the dialog These files contain your CCounterDlg class. This class defines the behavior of your application's main dialog. The dialog's template is in counter.rc, which can be edited in Microsoft Visual C++. ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named counter.pch and a precompiled types file named StdAfx.obj. Resource.h This is the standard header file, which defines new resource IDs. Microsoft Visual C++ reads and updates this file. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" to indicate parts of the source code you should add to or customize. If your application uses MFC in a shared DLL, and your application is in a language other than the operating system's current language, you will need to copy the corresponding localized resources MFC42XXX.DLL from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources translated to German.) If you don't do this, some of the UI elements of your application will remain in the language of the operating system. /////////////////////////////////////////////////////////////////////////////

    2010-06-02
    9
  • 签到新秀

    累计签到获取,不积跬步,无以至千里,继续坚持!
关注 私信 TA的资源