• 博客(0)
  • 资源 (2)

空空如也

计算器Java

Java编写的计算器,import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; class Jsqzj implements ActionListener { JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16; JFrame f; GridLayout c=new GridLayout(4,4); JTextField tf = new JTextField();

2014-04-15

插入排序算法c++

插入排序算法 //²åÈëÅÅÐò #include <iostream> using namespace std; void putout(int a[],int x,int y); void InsertSort(int a[],int size) { int go,arrow=1,pos,s; for(int x=size-1;x;x--)//³õʼ»¯²ÎÊý { go=0; int y=(size+x)/2; if(a[x-1]>a[y]) arrow=1; else arrow=-1; y+=arrow; int extra=(arrow+1)/2; while(y<size && y>x-1 && !go)//Ñ°ÕÒ²åÈëµã { if(a[x-1]*arrow<a[y]*arrow+extra) { if(arrow==1) pos=y-1; else pos=y; go=1; } y+=arrow; } if(!go && arrow==1)//²åÈëµãΪÖÕµãÓÒ±ßʱ£¬ÐÞÕý²åÈëµã { pos=size-1; go=1; } if(go)//²åÈë¹ý³Ì { s=a[x-1]; for(int m=x-1;m<pos;m++)//ðÅÝ { a[m]=a[m+1]; } a[pos]=s; } for(int n=0; n<size; n++) cout<<a[n]<<","; cout<<endl; } } /* void InsertSort(int a[],int n) { for (int i=1; i<n; i++) { int t=a[i]; int j; for (j=i-1; j>=0 && t<a[i]; j--) a[j+1]=a[j]; a[j]=t; } } */ //putout void putout(int a[],int y) { cout<<a[0]; for(int n=1;n<y;n++) cout<<","<<a[n]; cout<<endl; } void main() { char s='y'; while(s=='y') { int data[100], num, k; cout<<"ÇëÈ·¶¨Êý×Ö¸öÊý:"; cin>>num; cout<<"ÊäÈëÊý×Ö"<<endl; for(int i=0; i<num; i++) { cin>>k; data[i]=k; } cout<<"ÅÅÐò¹ý³Ìչʾ"<<endl; InsertSort(data,num); cout<<"½á¹û"<<endl; putout(data,num); cout<<"¼ÌÐøÊäÈ룺y£¬Í˳öÊäÈ룺n"<<endl; cin>>s; } }

2013-09-17

空空如也

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

TA关注的人

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