摘要: //输入一个大于6的偶数,这个数一定能写成两个素数的和,比如8=3+5;#include<iostream>using namespace std; int prime(int x);void gotbaha(int x);void main(){ int a; cin>>a; if((a<6)||(a%2==1)) cout<<"the wrong number"<<endl; else gotbaha(a); }int prime(int x){ int i;for(i=2;i<x;i++) if(x%i==0 阅读全文
posted @ 2013-02-23 16:02 叶城宇 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;class School{private: char*sname; int snumber,score;public: void show( ) {cout<<"sname is:"<< sname<<endl; cout<<"snumber is:"<< snumber<<endl; cout<<"score is:"<< score<<e 阅读全文
posted @ 2013-02-23 16:01 叶城宇 阅读(139) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;#include<cmath>class number {private :int son,mother;public: number (int son2,int mother2) { int a,b,k,i=0; if(son2>mother2) { a=son2;b=mother2;} else {a=mother2;b=son2;} for( ; ;i++) {if(a%b==0) break; else { k=a;a=b;b=k%b;} } son=s... 阅读全文
posted @ 2013-02-23 16:00 叶城宇 阅读(202) 评论(0) 推荐(0) 编辑
摘要: //应用调用函数的引用,将一维数组的最大值换成自己输入的一个X的数,再将数组输出;# include <iostream>using namespace std;int &fun(int a[],int b);int* max;void main (void){ int a[]={5,9,8,7,12,33,66,88,7},n,x; cout<<"please enter x"<<endl; cin>>x; n=sizeof(a)/sizeof(int); fun(a,n)=x; for(int i=0;i<n 阅读全文
posted @ 2013-02-23 15:59 叶城宇 阅读(153) 评论(0) 推荐(0) 编辑
摘要: # include <iostream>using namespace std;void move (int n,char a,char b){ cout<<n<<"盘"<<a<<" to "<<b<<endl;}void h1(int n,char x,char y,char z){ if(n==1) move(n,x,z); else { h1(n-1,x,y,z); move (n,x,z); h1(n-1,y,x,z); }}void main (){ int n 阅读全文
posted @ 2013-02-23 15:56 叶城宇 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;char dest[10] ;char* copystr(char source[], int m ,int x) { int i,j=0; for(i=m-1;i<x;i++) { dest[j]=source[i]; j++;} char *p=dest; return p; }void main(){ int i,m,x; char source[10] ; for(i=0;i< 10;i++) cin>>source[i]; cout<<"请输入0-10 阅读全文
posted @ 2013-02-23 15:55 叶城宇 阅读(150) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;void copystr(char source[],char dest[],int m ,int x) { int i,j=0 ; for(i=m-1;i<x;i++) { dest[j]=source[i]; j++;} }void main(){ int i,m,x; char source[10],dest[10]; for(i=0;i< 10;i++) cin>>source[i]; cout<<"请输入0-10之间的数"<<en 阅读全文
posted @ 2013-02-23 15:54 叶城宇 阅读(156) 评论(0) 推荐(0) 编辑
摘要: //某任务需要在A、B、C、D、E着5人中物色人员去完成,但派人受限于下列条件://(1)若A去,则B跟去(2)D、E两人中必有人去(3)B,C两人中必有人去,但只去一人//(4)C,D两人要么都去,要么都不去(5)若E去,则A,B都去#include<iostream>using namespace std;void print(int n);void main(){ for(int i=0;i<32;i++){ if(i>>4 && !((i & 8) ))continue; if(!((i&2) ) &&!(i 阅读全文
posted @ 2013-02-23 15:45 叶城宇 阅读(144) 评论(0) 推荐(0) 编辑
摘要: //某任务需要在A、B、C、D、E着5人中物色人员去完成,但派人受限于下列条件://(1)若A去,则B跟去(2)D、E两人中必有人去(3)B,C两人中必有人去,但只去一人//(4)C,D两人要么都去,要么都不去(5)若E去,则A,B都去#include<iostream>using namespace std;void print(int n);void main(){ for(int i=0;i<32;i++){ bool A=i&16,B=i&8,C=i&4,D=i&2,E=i&1; if(A && !B) cont 阅读全文
posted @ 2013-02-23 15:44 叶城宇 阅读(256) 评论(1) 推荐(0) 编辑
摘要: #include<iostream>#include<cstring>using namespace std;void main(){const char*state1="florida";const char*state2="kansas";const char*state3="euphoria";int len=strlen(state2);cout<<"increasing loop index;\n";int i;for(i=1;i<=len;i++){ cout. 阅读全文
posted @ 2013-02-23 15:40 叶城宇 阅读(360) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<sstream>using namespace std;void main(){freopen("testdata.txt","rt",stdin);for(string s;getline(cin,s); ){ int a,sum=0; for(istringstream a1(s);a1>>a;sum+=a); cout<<sum<<endl;}} 阅读全文
posted @ 2013-02-23 15:12 叶城宇 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<vector>#include<algorithm>#include<string>using namespace std;struct R{ string title; int rating;};bool operator<(const R&r1,const R&r2);bool worsethan(const R&r1,const R&r2);bool fillR(R& rr);void showR(const R& rr);void 阅读全文
posted @ 2013-02-23 15:10 叶城宇 阅读(162) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<vector>#include<string>using namespace std;struct R{ string title; int rating;};bool fillr(R & rr);void showr(const R & rr);void main(){vector<R>books;R temp;while(fillr(temp)) books.push_back(temp);int num=books.size();cout<<"siz 阅读全文
posted @ 2013-02-23 15:09 叶城宇 阅读(180) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>#include<iterator>#include<set>#include<string>using namespace std;void main(){ const int N=6; string s1[N]={"buffoon","thinkers","for","heavy","can","for"}; string s2[N]={& 阅读全文
posted @ 2013-02-23 15:08 叶城宇 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>#include<queue>using namespace std;void main(){ queue<int>s; s.push(1); s.push(2); s.push(3); cout<<"size::"<<s.size()<<endl; cout<<"front::"<<s.front()<<endl; cout<<"back: 阅读全文
posted @ 2013-02-23 15:06 叶城宇 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>#include<map>#include<algorithm>using namespace std;typedef int keytype;typedef pair<const keytype,string> pair1;typedef multimap<keytype,string> mapcode;void main(){ mapcode codes;codes.insert(pair1(415,"san francisco") 阅读全文
posted @ 2013-02-23 15:05 叶城宇 阅读(165) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<algorithm>#include<string>#include<map>using namespace std;/*struct T1{ int v; bool ope1(const T1&a){ return(v<a.v); }};struct T2{ int v;};struct cmp{ const bool op(const T2 &a,const T2 &b ) { return (a.v<b.v);}};*/void mian(){ //m 阅读全文
posted @ 2013-02-23 15:04 叶城宇 阅读(143) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<list>#include<iterator>using namespace std;void main(){list<int>one(5,2);int stuff[5]={1,2,4,8,6};list<int>two;two.insert(two.begin(),stuff,stuff+5);int more[6]={6,4,2,4,6,5};list<int>three(two);three.insert(three.end(),more,more+6);cout 阅读全文
posted @ 2013-02-23 15:03 叶城宇 阅读(121) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<list>#include<string>using namespace std;void main(){ list<int>lis; list<int>::iterator li; for(int i=0;i<3;i++) { lis.push_front(i), lis.push_back(i); } lis.sort(); cout<<"size::"<<lis.size()<<endl; for(li=lis.b 阅读全文
posted @ 2013-02-23 15:02 叶城宇 阅读(124) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>//#include<list.h>#include<iterator>#include<vector>#include<string>using namespace std;void main(){ string s1[4]={"fine","fish","fashion","fate"}; string s2[2]={"busy","bate"}; string s3[3]={ 阅读全文
posted @ 2013-02-23 15:01 叶城宇 阅读(99) 评论(0) 推荐(0) 编辑