|
|
|
|
|
摘要:
c和c++中变量是必不可少的,如果把内存看做一栋寝室的话,那么变量名可以看做你所住的寝室号,里面住的人就是变量的值,变量名的定义只能使用字母,数字,和下划线,并且变量名的首字符不能是数字,只能是字符和下划线。变量有定义和赋值,int n=5;就是定义和赋值在一起实现的。我们通过变量的名字就可以取出里面的值,就相但与知道了寝室好我们就可以找到那里面住着的人一样。变量的运算其实就是取出里面的值进行的运算。 阅读全文
posted @ 2012-10-26 15:27
903829182
阅读(78)
推荐(0)
编辑
摘要:
#include<iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>using namespace std;const int Max = ( 1 << 20 ) + 5;long long len[Max],hash[Max];int n;void pre( ){ for( int i = 1; i <= Max / 2; ++i ) { for( int j = i + i; j < Max; j += i 阅读全文
posted @ 2012-10-26 15:07
903829182
阅读(148)
推荐(0)
编辑
摘要:
所谓序列式容器,其中的元素都可序,但未必有序,C++语言本身提供了一个序列式容器arry,STL再提供vector,list,deque,stack,queue,priority_queue等等序列式容器,其中stack和queue只是将deque改头换面,技术上被归类为一种配接器.一 vectorvector的数据安排以及操作方式与arry十分相似,唯一的差别在于arry是静态的,一旦配置了就不能改变,vector是动态空间.stl的erase和insert 的实现效率低得可怜,每erase一个元素,竟然要把后面所有的节点全部移动,O(n^2)的复杂度.vector有个resize函数,原型 阅读全文
posted @ 2012-10-26 15:03
903829182
阅读(174)
推荐(0)
编辑
摘要:
#include<stdio.h>#define max 100///////////////////////typedef struct{ int queue[max]; int front; int rear; int cout;}SeqQueue;/////////////////////////int InSeqQueue(SeqQueue &s){s.cout=0;s.front=0;s.rear=0;}/////////////////////////////////int InQuee(SeqQueue &s,int x){if(s.cout>0 阅读全文
posted @ 2012-10-26 14:53
903829182
阅读(99)
推荐(0)
编辑
摘要:
#include<stdio.h>/////////////////////////////////////typedef struct Node{int data; struct Node *next;}LNode,*LinkList;////////////////////////////////////////////int InList(LNode &L){ LinkList p; p=&L; p=new Node(); p->data=0; p->next=NULL; return 0;}//////////////////////////// 阅读全文
posted @ 2012-10-26 14:52
903829182
阅读(122)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<malloc.h>#include<stdlib.h>////////////////////////////////////////////////typedef struct{int *element;int length;int listsize;}SeqList;////////////////////////////////////////////////int InitSeqList(SeqList &S){ S.element=(int *)malloc(sizeof(int)*100 阅读全文
posted @ 2012-10-26 14:51
903829182
阅读(115)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<malloc.h>#include<stdlib.h>////////////////////////////////////////////////typedef struct{int *element;int length;int listsize;}SeqList;////////////////////////////////////////////////int InitSeqList(SeqList &S){ S.element=(int *)malloc(sizeof(int)*100 阅读全文
posted @ 2012-10-26 14:49
903829182
阅读(140)
推荐(0)
编辑
摘要:
/*#include<iostream>#include<iomanip>#include<stdlib.h>using namespace std;int main() {system("color 3E");int a=10;int &b=a;a=a*a;cout<<a<<" "<<b<<endl;b=b/5;cout<<a<<" "<<b<<endl;return 0;}*/#include 阅读全文
posted @ 2012-10-26 14:37
903829182
阅读(166)
推荐(0)
编辑
摘要:
/*#include<iostream>#include<stdlib.h>#include<string>using namespace std;int main(){string st[5];system("color 3E");int i;cout<<"输入五个字符串:\n"; cout<<"*******\1 \1 \1 \1 \1 \1 \1 \1*******\n";for(i=0;i<5;i++){cin>>st[i];}for(i=0;i&l 阅读全文
posted @ 2012-10-26 14:36
903829182
阅读(142)
推荐(0)
编辑
摘要:
/*#include<iostream>#include<stdio.h>#include<stdlib.h>#include<windows.h>using namespace std;int main(){system("color 3E");cout<<"响三次:\n";Sleep(1000);cout<<'\a';Sleep(1000);cout<<'\a';Sleep(1000);cout<<'\a'; 阅读全文
posted @ 2012-10-26 14:35
903829182
阅读(146)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<string.h>int main(){char word[100];scanf("%s",word);int len=strlen(word);for(int i=1;i<=len;i++)if(len%i==0){int ok=1;for(int j=i;j<len;j++)if(word[j]!=word[j%i]){ok=0;break;}if(ok){printf("%d\n",i);break;}}return 0;} 阅读全文
posted @ 2012-10-26 14:34
903829182
阅读(153)
推荐(0)
编辑
摘要:
#include<iostream>#include<string>using namespace std;string add(string a, string c) { char ab[255]; memset(ab,'\0',sizeof(char)*255); for(unsigned int i_=0;i_< a.length();i_++) ab[i_]=a[a.length()-i_-1]; char cd[255]; memset(cd,'\0',sizeof(char)*255); for(unsigned int 阅读全文
posted @ 2012-10-26 14:33
903829182
阅读(175)
推荐(0)
编辑
摘要:
#include<iostream>#include<string.h>using namespace std;const int max=1000;struct bign{int len,s[max];bign(){memset(s,0,sizeof(s));len=1;}bign operator = (const char * num){len=strlen(num);for(int i=0;i<len;i++)s[i]=num[len-1-i]-'0';return *this;} bign operator = (int num){cha 阅读全文
posted @ 2012-10-26 14:32
903829182
阅读(117)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<stdlib.h>int main(){ system("color 3E");int i=1,j=1,n;long sum=0,s=0;printf("输入项数N\n");scanf("%d",&n);if(n<1){printf("the n must be no less than 1!\n");return 0;} for(;i<=n;i++){for(;j<=i;j++){s=s+i;}sum=sum+s 阅读全文
posted @ 2012-10-26 14:31
903829182
阅读(103)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<math.h>int main(){long n,m,a[100000];int i,j,k,t=1;scanf("%ld",&n);a[0]=2;m=3; while(m<n){k=0;while(a[k]*a[k]<=m)if(m%a[k]==0){m=m+2; k=1;}elsek++;a[t++]=m;m=m+2;}for(i=0;i<t-1;i++)printf("%ld\n",a[i]);return 0;} 阅读全文
posted @ 2012-10-26 14:30
903829182
阅读(96)
推荐(0)
编辑
摘要:
#include<iostream>#include<math.h>#include<stdlib.h>using namespace std;int main(){ system("color 3E"); double y;int x,m;for(y=1;y>=-1;y-=0.1){m=acos(y)*10;cout<<m;for(x=1;x<m;x++)cout<<" ";cout<<"*";for(;x<62-m;x++)cout<& 阅读全文
posted @ 2012-10-26 14:29
903829182
阅读(122)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<string.h>int main(){char str[30],ch;int i=0,j; gets(str);for(i,j=strlen(str);i<j;i++,j--){ch=str[i];str[i]=str[j-1];str[j-1]=ch;}puts(str);return 0;} 阅读全文
posted @ 2012-10-26 14:28
903829182
阅读(118)
推荐(0)
编辑
摘要:
/*#include<stdio.h>void main(){ printf(" ******用指针访问变量*******\n");int a=521,*p=&a;printf(" %d %d\n",&a,p);printf(" %d %d\n",*&a,*p);printf(" %d %d\n",(&a)[0],p[0]);}*///&&&&&&&&&&&&&& 阅读全文
posted @ 2012-10-26 14:28
903829182
阅读(95)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<stdlib.h>void main(){long n,m,r,t,c;system("color 3E");printf("输入两个数\n");scanf("%ld%ld",&n,&m);if(n<1||m<1){printf("输入错误\n");exit(0);}if(n>m){t=n;n=m;m=t;}c=m*n;r=m%n;while(r!=0){m=n;n=r;r=m%n;}printf(&quo 阅读全文
posted @ 2012-10-26 14:27
903829182
阅读(104)
推荐(0)
编辑
摘要:
#include<stdio.h>#include<stdlib.h>void main(){char ch;int a=0,b=0,c=0,d=0;system("color 3E");printf("输入字符\n");ch=getchar();while(ch!='\n'){if(ch>='A'&&ch<='z')a++;else if(ch==' ')b++;else if(ch>='0'&&ch 阅读全文
posted @ 2012-10-26 14:25
903829182
阅读(121)
推荐(0)
编辑
|
|