自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

kunkunTalk

蜗牛背着那重重的壳

  • 博客(118)
  • 问答 (1)
  • 收藏
  • 关注

原创 Java day04 类 封装

class Car{ //对象的特点在于封装数据 String color="red"; int wheel_num=4; void run() { System.out.println(color+"..."+wheel_num); }}class CarDemo { public static void main(String[] args) { Car

2016-03-17 10:43:39 276

原创 Java day03 进制转换(3)索引表 数组实现 十进制向各进制转换

/*十进制向其他进制转换*/class SystemChange{ public static void trans(int num,int base,int offset) {//源数据 基数 偏移量 char []tab={'0','1','2','3', '4','5','6','7', '8','9','A','B', 'C','D','E','

2016-03-13 23:57:28 308

原创 Java day03 进制转换(2)索引表 数组实现

/*索引表实现十进制到16进制转换,正负数均可*/class DecToHex_Table{ public static void toBin(int num) { int step=1; char []tab={'0','1'}; char []rec=new char[32]; int pos=rec.length; while(num!=0) { rec

2016-03-13 23:55:33 308

原创 JAVA day03 数组的应用,查找,求最值与基本排序方式

class arrayMax { public static int FindMax(int []a) { int max; max=a[0]; for(int i=1;i<a.length;i++) { if(a[i]>max) max=a[i]; } return max; } public static void SelectSortMax(

2016-03-13 23:53:35 283

原创 Java day03 数组的定义和初始化

class ArrayDemo{ public static String getType(Object o) { return o.getClass().toString(); } public static void main(String []args) { //数组初始化方式1 int []a=new int[3];//数组(引用型之一),声明变量时即有默认初始化值

2016-03-13 23:51:21 234

原创 位运算,大小写转换

#include //已知事实是,65的二进制是1000001, 97的二进制是1100001,97前不是字母,因而大写字母对应的ASCII码//二进制第5(默认最低位为第0位)位皆为0,小写字母的ASCII码二进制第五位皆为1int main(){ char ch,tmp; printf("请输入您要转换的字母"); ch=getchar();//接收输入字符 tmp=getch

2016-03-13 23:47:20 956

原创 Java day02 基本语句练习 进制转换

/*十进制转换到十六进制使用 与,移位操作,三目运算符,强制类型转换*///当前存在结果是逆向的问题,打算用String解决class DecToHex{ public static void main(String []args) { int num=39,res;//int型占4字节,有8个16位足够。 char []hex=new char[8]; res=num;

2016-03-13 23:44:53 279

原创 Java day02 方法(交换数据,普通形式)

//数组元素管用因为它们存在于堆中{//注意:对于数组元素,可以用交换角标的形式 swap(jint []a,int b,int c)?/b,c是角标class Function { public static void swap(int a,int b) {//这个不管用,因为这些变量存在于栈中 int tmp; tmp=a; a=b; b=tmp; }

2016-03-13 23:11:41 262

原创 Java day02 九九乘法表

class MultipleTable { public static void main(String[] args) { for(int i=1;i<=9;i++) { for(int j=1;j<=i;j++) { System.out.print(j+"*"+i+"="+i*j+"\t"); } System.out.println();

2016-03-13 23:06:05 227

原创 java day02 for循环的进一步理解

//对for循环的进一步理解,注意执行顺序class AboutFor{ public static void main(String[] args) { int x=1; for(System.out.println("a");x<3;System.out.println("c"),x++) { System.out.println("d"); //x++;

2016-03-13 22:57:24 246

原创 Java day02 类型转换(2)

class Operator { public static void main(String[] args) { //取模 //有负数参与的取模运算,绝对值左<右时,结果等于被模数 JAVA System.out.println(-6%5);//-1 System.out.println(4%-5);//4 /*int a;//java中必须显式给变量赋值,否则

2016-03-13 22:54:43 311

原创 Java day02 for循环练习 带星图案

class PatternFor { public static void main(String[] args) { for(int x=0;x<5;x++) { for(int y=0;y<4;y++) { System.out.print("*"); } System.out.println(); } System.out.println

2016-03-13 22:37:53 557

原创 java day02 交换数据

class SwapBySubstract_XOR{ public static void main(String []args) { int a=3,b=8; a=a+b; b=a-b; a=a-b; System.out.println("a="+a+" b="+b); a=a^b; b=a^b; a=a^b; System.out.println("

2016-03-13 22:27:37 200

原创 Java day02 类型转换

class TypeChange{ public static void main(String []args) { byte b=3; //自动类型提升 // b=b+2;//2默认为整型 //强制类型转换 b=(byte)(b+2);//(byte)2+b 也不行 System.out.println('a'+1);//'a'是char类型,占两个字节,

2016-03-13 22:14:51 250

原创 java dya01 HelloWorld与环境变量

class hello{ public static void main(String []args) { System.out.println("Hello"); }}/*cmdjava hello.javajavac helloclasspath 配置java 环境变量,环境变量后加了分号,先在环境变量中寻找class文件,再在当前目录中寻找,若无分号,则只在环境变

2016-03-13 22:08:13 264

原创 文件相关

#include #include int main(){ FILE *fp=NULL; char ch; fp=fopen("2.txt","r"); ch=fgetc(fp);//fgetc(指向文件的指针) 每使用一次该函数,指向当前文件读、写字符的指针后移一个 while(ch!=EOF)//对于二进制文件 使用feof(文件指针)函数与EOF同义 { putc

2016-02-25 16:19:50 276

原创 文件合成器

#include #include /*使用方式:输入图片名以及所要合并的文件名,以及待输出的结果文件名(若需要修改扩展名为rar,则合并文件也需为rar) 最终掩人耳目*/int checkOpen(char filename[],int n,FILE *&fp){ // n=20; fp=NULL; fp=fopen(filename,"rb"); if(!fp) {

2016-02-25 16:13:04 676

原创 数据结构之顺序表基本操作

/** ------------------------------------------------| 0无值 |1 |…………|length-1 |…………|MaxSize-1 | ------------------------------------------------*/#include #define MaxSize 100#define NULL 0

2015-05-27 18:56:51 1722

原创 结构体之投票系统

运行环境:vc6.0/*需求:无记名投票,输出投票结果目的:使用结构体描述:10个投票人,使用数字投票,每个候选人结构体包括名字和票数*/#include #include #define N 3//候选人#define V 10//投票人struct Candidate{ char name[20]; int vote;};int main(){ Candi

2015-05-16 20:05:18 2044 2

原创 返回值为指针的函数——学生成绩单

/*需求:根据学号打印出对应学生的成绩单目的:练习使用返回类型为指针的函数*/#include #include #include #define N 5int main(){ double score[N][2];//所有学生的所有成绩 int random(double [][2],int); double *output(double (*p)[2],int); r

2015-05-09 12:08:25 531

原创 指向函数的指针——指向函数的指针作为函数的形参

#include int main(){ int a,b,c; //int (*func)(int,int); int add(int,int); int sub(int,int); int process(int,int,int (*func)(int,int)); printf("输入a,b\n"); scanf("%d%d",&a,&b);//逗号隔开// func=

2015-05-09 11:46:58 771

原创 输出数组指定位置元素

/*需求:输出数组指定位置的元素目的:练习二维数组和指向数组的指针*/#include int main(){ int a[2][3]={12,12,3,32,22,45}; /*int *p; p=a;//error C2440: '=' : cannot convert from 'int [2][3]' to 'int *' */ /*int *p[4];//指针数组,

2015-05-05 17:37:56 2498

原创 结构体练习——计算输入的日期为本年度第几天

/*需求:特定的某天是该年的第几天 输入:年月日 输出:根据输入计算它是本年的第几天*/#include using namespace std;struct Date{//使用结构体定义输入的具体日子 int year; int month; int day;};int days(Date,int&);//对函数的声明,注意在函数变量定义中不能有结构体成员int ma

2015-05-04 22:08:44 2647

原创 结构体类型数据作为函数参数(三种方法

点击打开链接将一个结构体中变量中的数据传递给另一个函数,有以下三种方法。需要的朋友可以过来参考下,希望对大家有所帮助(1)用结构体变量名作为参数。复制代码代码如下:#include#includeusing namespace std;struct Student{string name;

2015-05-04 21:34:01 3027

原创 时钟类的基本实现

---------------------------2012.12-------------------------

2015-05-04 20:23:01 545

原创 选择,冒泡排序

如题

2015-05-04 14:36:55 333

原创 数组逆序输出元素

/**需求:指针实现数组元素的逆序输出*/#include #define MAX 10int main(){int a[MAX];int reverse(int*,int);for(int i=0;ia[i]=i+1;reverse(a,MAX);//实参for(int k=0;kprintf("%d  ",*(a+k));return 0;

2015-04-25 23:13:39 1484

原创 求n以内的数的和

#include using namespace std;int main(){ int i,sum,n; cout<<"请输入一个不大于n的整数"; cin>>n; i=0; sum=0; while (i<n)//有些东西得算一算,把<=改为=就行了 sum=sum+(++i);//先i=i+1,再sum=sum+i

2012-11-30 09:19:07 470

原创 两个数的最大公约数与最小公倍数

#include using namespace std;int main(void){ int p,r,n,m,temp; cout<<"请输入两个正整数n,m"<<'\n'; cin>>n>>m; if(n<m) { temp=n; n=m; m=temp;//把大数赋给N,小的数赋给m } p=n*m; // 当除数不为0时

2012-11-25 11:17:43 404

原创 统计一个字符串中字母、数字,空格及其他的个数

#include using namespace std;int main(){ char c; int letter=0,space=0,digh=0,other=0; cout<<"请输入一行字符:"; while ((c=getchar())!='\n')//一开始是while (c=getchar()!='\n')非!=的运算优先级高于=,所以输出地c非0即1

2012-11-25 11:15:01 6162

原创 多门成绩判断及格与不及格门数

#include using namespace std; int main( ) { int i=0,score,n,c;cout<<"请输入5个成绩:"<<'\n';cin>>score;for(n=0,c=1;c<=5;c++) if (score100)cout<<"请重新输入分数!";else if(score>=

2012-11-06 10:52:07 951

原创 水仙花数

#include using namespace std;int main(){int i,j,k,n;//n为该3位数,i是百位,j是十位,k是个位cout<<"水仙花数是:"<<endl;for(n=100;n<1000;n++)//for循环,确保是一个三位数{i=n/100;//求出百位数字j=n/10-i*10;//求出十位数字,其中尤其注意后面的-i*1

2012-11-05 17:45:57 262

转载 平面直角坐标系内两点间的距离

修改前#include #include using namespace std;int main(){ double x1,y1,x2,y2,d; cout<<"请输入第一点坐标:"; cin>>x1>>y1; cout<<"请输入第二点坐标 :"; cin>>x2>>y2; d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-

2012-11-03 12:31:03 2101

原创 圆的周长,面积,球的体积和表面积

#include //预处理指令#include #include using namespace std;//函数外的声明int main()//函数首部{ double r,h,c,s,S,V1,V2;//双精度 double pi=3.1415; cout<<"请输入圆的半径和圆柱的高";//友好界面 cin>>r>>h;//输入 c=2*pi*

2012-11-03 12:21:18 698

原创 百分制成绩与五级分制转换

tream>using namespace std;int main(){ int a; char A,B,C,D,E; cout<<"请输入分数"; cin>>a; if (a>100) cout<<"请重新输入分数!"; else if(a>=90) cout<<A; else if(a>=80) cout<<B;

2012-11-03 12:14:42 10893

原创 分段函数

修改前#include #include #include using namespace std;int main{)[ int x,y; cin>>x; if (x<1) y=x; else if (x>=10) y=3x=11; else y=2x-1; cout<<y<<endl;return 0;]修改后#in

2012-11-03 12:07:50 420

原创 华氏温度转为摄氏温度

#include #include using namespace std;\int main(){double F,c;cout<<"请输入一个华氏温度值:";//注意若要显示 请输入一个华氏温度值,则应为cout<<!!!!!!cin>>F;c=(5.0/9.0)*(F-32);//默认5/9中的5和9是整型,因而此语句中把5变为5.0把9变为9.0co

2012-11-03 11:52:50 1157

原创 3个数中的最大值(不用数组)

#include using namespace std;int main () //函数头{ int a,b,c,max1,max2,max; cout"请输入三个数"; cin>>a>>b>>c; if (a<b) max1=b; else max1=a; if (b<c) max2=c; else max2=b; if

2012-10-29 16:36:13 556

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除