2012年12月7日

摘要: package lyt;import java.util.*;public class Lyt6 {public static void main(String[] args) {// TODO Auto-generated method stubScanner input=new Scanner(System.in); int []arr=new int[100]; int max=0,count=0,m=0; System.out.print("请输入一串字符串:"); for(int i=0;i<100;i++) { arr[i]=input.nextInt() 阅读全文
posted @ 2012-12-07 23:56 木本 阅读(174) 评论(0) 推荐(0) 编辑
摘要: C/C++中int/long/float/double数值类型与字符串互相转换[总结]memcpy方法可以实现将int等保存到字符类型的数组中。示例:long long_data=-9828;unsigned char data[4];memcpy(data,&t,4); //将long类型的数据用4个char保存。long my_long_data=0;memcpy(&tt,data,4);//从4个char中还原出long类型数据。一、int/long/float/double转字符串方法1:itoa, ltoa(a表示array数组的意思)头文件:stdlib.h示例:i 阅读全文
posted @ 2012-12-07 23:56 木本 阅读(286) 评论(0) 推荐(0) 编辑
摘要: package lyt;import javax.swing.*;public class Lyt5 {public static void main(String[] args) {// TODO Auto-generated method stubString year=JOptionPane.showInputDialog(null,"请输入年份:","梁燕婷",JOptionPane.QUESTION_MESSAGE);String weekend=JOptionPane.showInputDialog(null,"请输入改年第一天的星 阅读全文
posted @ 2012-12-07 23:55 木本 阅读(172) 评论(0) 推荐(0) 编辑
摘要: package lyt;import javax.swing.JOptionPane;public class Lyt4 {public static void main(String[] args) {// TODO Auto-generated method stubdouble sum=0,s=-1;for(long i=1;i<99999999;i++){s=-s;sum=sum+1.0/(2*i-1)*s;}JOptionPane.showMessageDialog(null, "PI = " + 4*sum,"ÁºÑ 阅读全文
posted @ 2012-12-07 23:54 木本 阅读(198) 评论(0) 推荐(0) 编辑
摘要: package lyt;public class Lyt3 {public static void main(String[] args) {// TODO Auto-generated method stubfor(int j=0,i=8;j{for(int m=8-j;m>0;--m) System.out.print(" ");//System.out.print(" 1");for(int n=0;n<=j;n++){System.out.printf("%4s",(int)(Math.pow(2, n)));}f 阅读全文
posted @ 2012-12-07 23:53 木本 阅读(170) 评论(0) 推荐(0) 编辑
摘要: package lyt;import javax.swing.JOptionPane;public class Lyt1 {public static void main(String[] args) {// TODO Auto-generated method stubdouble fee=10000,sum=0,sum1=0;for(int i=0;i<14;i++){if(i<14&&i>9){ sum=sum+fee; fee=fee+fee*5.0/100;}if(i<10){ fee=fee+fee*5.0/100; sum1=fee;}}J 阅读全文
posted @ 2012-12-07 23:52 木本 阅读(152) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;ifstream infile1;ifstream infile2;ifstream infile3;class qclx{string checi; string start,end;string type;string distance;string statime,endtime;double price;int zws;public:void input();void output();friend void change1();};void qclx::input(){infile 阅读全文
posted @ 2012-12-07 23:51 木本 阅读(212) 评论(0) 推荐(0) 编辑
摘要: #include#includeusingnamespacestd;intGreat();intn1=0,n2=0;intmain(){charc='Y';while(c=='Y'){Great();cout<<"是否想继续进行游戏???YorN:";cin>>c;system("cls");}cout<<"游戏者赢得次数:"<<n1<<endl;cout<<"游戏者失败的次数:"<<n2<&l 阅读全文
posted @ 2012-12-07 23:50 木本 阅读(148) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;ifstream infile1;ifstream infile2;ifstream infile3;class qclx{string checi; string start,end;string type;string distance;string statime,endtime;double price;int zws;public:void input();void output();friend void change1();};void qclx::input(){infile 阅读全文
posted @ 2012-12-07 23:49 木本 阅读(490) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int main (){int a[9999],i,b=0,n,c,z=0;while(cin>>n){ b=0;c=n; for(i=0;ia[i]=i+1; while(c--) { z=0; for(i=0;i if(a[i]!=0){ b++;z++; if(b==3) {a[i]=0; b=0; }} if(z==1) break; }for(i=0;iif(a[i]!=0)cout<<a[i]<<endl;}return 0;} 阅读全文
posted @ 2012-12-07 23:47 木本 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;ifstream infile1;ifstream infile2;ifstream infile3;class qclx{string checi; string start,end;string type;string distance;string statime,endtime;double price;int zws;public:void input();void output();friend void change1();};void qclx::input(){infile 阅读全文
posted @ 2012-12-07 23:39 木本 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 实验要求:自定义如下形式的一个称为point的类,其对象表示平面上的一个点(x,y),并通过类成员方式对该类重载二目运算符“+”和“^”,用来求出两个对象的和以及两个对象(平面点)的距离。各运算符的使用含义(运算结果)如下所示:(1.2,-3.5)+(-1.5,6)=(-0.3,2.5);(1.2,-3.5)^(-1.5,6)=9.87623。编写主函数,说明类对象,而后通过类对象实现所定义的相关运算(以验证其正确性)。classpoint{doublex,y;public:point(doublex0=0,doubley0=0){x=x0;y=y0;}pointoperator+(point 阅读全文
posted @ 2012-12-07 23:38 木本 阅读(512) 评论(0) 推荐(0) 编辑
摘要: #include#includeusingnamespacestd;classStudent{public:Student();voidoutput();voidchange();voidsort1();voidsort0();voidSum();private:stringname;stringsex;doublescore[5];doubleold;stringclass_1;stringstr[5];};Student::Student(){name="梁燕婷";sex="女";old=19;class_1="软件114班";s 阅读全文
posted @ 2012-12-07 23:35 木本 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 假设某商店有如下几种货品:衬衣、帽子、立柜。每一种货物都有与其关联的说明信息。衬衣:单价、产地、布料;帽子:单价、产地、布料、样式(平顶或尖顶);立柜:单价、产地、木料、颜色。对这些商品的操作有:商品的进库(增加某类商品及其库存量),商品的出库(减少某类商品及其库存量),某类货品总价格的计算。要求自行设计数据结构,用类的继承与派生关系将上述的各种货品表示出来,并使用类的构造函数来初始化每一类对象的初始数据。而后将上述的商品管理计算机化,完成操作要求的功能。二、实验过程(实验步骤、记录、数据、)#include#includeusingnamespacestd;classShirt{public 阅读全文
posted @ 2012-12-07 23:28 木本 阅读(509) 评论(0) 推荐(0) 编辑
摘要: 了解多态性的概念,了解虚函数的作用及使用方法,了解静态关联和动态关联的概念和用法,了解纯虚函数和抽象类的概念和用法。实验要求:声明抽象基类Shape,由它派生出3个派生类:Circle(圆形)、Rectangle(矩形)、Triangle(三角形),用一个函数printArea分别输出以上三者的面积,3个图形的数据在定义对象时给定。二、实验过程(实验步骤、记录、数据、)#includeconstdoublePI=3.1415925;classShape{public:virtualdoublearea()const{return0;}virtualvoidshapeName()const=0; 阅读全文
posted @ 2012-12-07 23:26 木本 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 自定义三个text型磁盘文件f1.txt、f2.txt和f3.txt,并对它们进行指定的读写操作:先往f1.txt以及f2.txt中写出数据,之后再将它们读入而形成f3.txt文件。实验要求:通过使用运算符“>>”和“<<”,对自定义的text型磁盘文件进行如下的指定操作。(1)对i=1,2,3,...,15,计算d=i*i+0.5,并将15个结果写出到自定义的text型磁盘文件f1.txt中(注意,f1文件中的数据从小到大有序);(2)对i=1,2,3,...,10,计算d=10*i+0.5,并将10个结果写出到自定义的text型磁盘文件f2.txt中,而后再写出第1 阅读全文
posted @ 2012-12-07 23:25 木本 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 1.设计并编制自定义函数chgStr,完成指定功能;而后在main中调用chgStr验证其正确性。2.通过指针参数的使用实现“双向传值”:函数参数为字符指针;调用该函数时,对应实参为一维字符数组名;通过指针参数op将结果带回到调用函数中去。实验要求:编制具有如下原型的函数:voidchgStr(char*ip,char*op);负责将ip所指输入串中的各字符按照指定规则进行变换后,存放到由op指向的输出串中。即要从头到尾逐字符地对ip所指向的字符串进行如下处理:(1)若ip所指当前字符为字母,则将其改变大小写后存放到结果串op中。(2)若ip所指当前字符是一个数字字符,则将其变换为另一个数字字 阅读全文
posted @ 2012-12-07 23:19 木本 阅读(244) 评论(0) 推荐(0) 编辑
摘要: #includeusingnamespacestd;classComplex{public:Complex(doubler=0,doublei=0):real(r),imag(i){}voidinput(){cin>>real>>imag;}voiddisplay(){cout<<"("<<real<<","<<imag<<"i)"<<endl;}doublereal;doubleimag;};intmain(){Complexoperat 阅读全文
posted @ 2012-12-07 23:12 木本 阅读(224) 评论(0) 推荐(0) 编辑
摘要: #includeusingnamespacestd;classComplex{public:Complex(doubler=0,doublei=0):real(r),imag(i){}Complexoperator+(Complex&c1);Complexoperator-(Complex&c1);Complexoperator*(Complex&c1);Complexoperator/(Complex&c1);voidinput(){cin>>real>>imag;}voiddisplay(){cout<<"(&q 阅读全文
posted @ 2012-12-07 23:11 木本 阅读(308) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;struct student{int num;char name[20];student *next;};void print(student *p1);student *creat(student *stu);student *del(student *head);student *insert(student *head,student *q);int main(){student *p1,*stu,*q;q=new student;cout<<"输入一个要插入的num和name"< 阅读全文
posted @ 2012-12-07 23:09 木本 阅读(117) 评论(0) 推荐(0) 编辑

导航