虫虫首页|资源下载|资源专辑|精品软件
登录|注册

NAMESPACE

  • 写了一个小程序

    写了一个小程序,听往上说什么将类的申明放在NAMESPACE里面的话,该类就不能再派生了,我做的这个程序还可以派生,不知道这是怎么回事

    标签: 程序

    上传时间: 2013-12-23

    上传用户:yuchunhai1990

  • c++图书管理系统 include <iostream> #include <iomanip> #include <string> #include <

    c++图书管理系统 include <iostream> #include <iomanip> #include <string> #include <fstream>//输入/输出文件流类 using NAMESPACE std const int Maxr=100 //最多的读者 const int Maxb=100 //最多的图书 const int Maxbor=5 //每位读者最多借五本书 //读者类,实现对读者的信息的描述

    标签: include lt gt iostream

    上传时间: 2013-12-18

    上传用户:拔丝土豆

  •   在本光盘中提供了由谭浩强编著的《C++程序设计》(清华大学出版社出版)一书中各章的例题程序以及全部习题的参考解答

      在本光盘中提供了由谭浩强编著的《C++程序设计》(清华大学出版社出版)一书中各章的例题程序以及全部习题的参考解答,以方便教师进行教学,也便于读者上机运行这些程序以及在此基础上修改和调试程序。 程序按章设立文件夹(子目录),例如文件夹c12中包含的是第12章全部例题的程序。程序的文件名以c开头,与例题号一一对应,如c5-7.cpp是第5章例5.7的程序。对于教材中同一例题中包含两个或多个程序的,在文件名中加了顺序号,如c10-4-1.cpp是例10.4的第1个程序,c10-4-2.cpp是例10.4的第2个程序。 教材中所有的程序都是符合C++标准规定的,在GCC中能通过,但有的程序在Visual C++ 6.0中通不过。如果在Visual C++ 6.0环境下运行程序,需要对程序作一些修改。例如,如果程序c10-4-1.cpp在Visual C++ 6.0环境下编译,第1行应改为“include <iostream.h>”,并将第2行“using NAMESPACE std ”取消即可顺利通过编译,其他类似。我们在教材的例题程序中还提供了能在Visual C++ 6.0环境下运行的程序,在文件名中加了"(VC)"字样,如c10-4-2(VC) 表示它是对程序c10-4-2修改后能用于Visual C++ 6.0环境的程序。

    标签: 光盘 谭浩强 程序设计 清华大学

    上传时间: 2017-02-03

    上传用户:youth25

  • This inspired me to make this tool. This tool is not a professional one but shows an example which m

    This inspired me to make this tool. This tool is not a professional one but shows an example which makes use of the System.Diagnostics NAMESPACE. With this tool, you can write small console based Java programs, compile and run. Just a way to practically learn Java.

    标签: This tool professional inspired

    上传时间: 2014-01-10

    上传用户:561596

  • toj 4022源代码

    #include <iostream> using NAMESPACE std; int main(){ int t; cin>>t; while(t--){ long long n; cin>>n; if(n%2==1) cout<<(n*n-1)/4<<endl; else if (n%4==0) cout <<(n*n)/4-1<<endl; else{ if(n==2) cout<<1<<endl; else{ long long k=n/2-1; cout <<k*k+2*k-3<<endl; } } } return 0; }

    标签: 天津大学acm4022 代码

    上传时间: 2015-04-20

    上传用户:nr607

  • c语言程序源

    #include <iostream> using NAMESPACE std; class Student { public: Student(int, int); int num; int grade; }; Student::Student(int n, int g) { num = n; grade = g; } int maxGradeIndex(Student* s) { int maxGrade, index = 0, i = 0; maxGrade = s[0].grade; for (i = 0; i<5; i++) { if (s[i].grade > maxGrade) { maxGrade = s[i].grade; index = i; } } return  index; } int main() { Student a[5] = { Student(1, 86), Student(2, 60), Student(3, 72), Student(4, 95), Student(5, 66) }; int maxGradeStNum = maxGradeIndex(a); cout << "成绩最好学生的学号是:" << a[maxGradeStNum].num << endl; cout << "成绩最好学生的成绩是:" << a[maxGradeStNum].grade << endl; getchar(); return 0; }

    标签: c语言 程序

    上传时间: 2016-04-23

    上传用户:burt1025

  • 编写一个程序,要求用户输入一年12个月每月的降雨总量,并采用一个float数组存储。

    程序显示: 一年内总降雨量、平均每月的降雨量、降雨量最大的月份和最小的月份。 #include<iostream> using NAMESPACE std; #include<stdlib.h> int main() .. .. .. cout<<"降雨量最小的月份是:"<<minyue<<"月   "<<"降雨量为:"<<min<<endl; }

    标签: float 编写 程序 用户 数组 存储 输入

    上传时间: 2018-03-27

    上传用户:shayusha

  • 数据结构实验

    #include <stdio.h>   #include <stdlib.h> ///链式栈      typedef struct node   {       int data;       struct node *next;   }Node,*Linklist;      Linklist Createlist()   {       Linklist p;       Linklist h;       int data1;       scanf("%d",&data1);       if(data1 != 0)       {           h = (Node *)malloc(sizeof(Node));           h->data = data1;           h->next = NULL;       }       else if(data1 == 0)       return NULL;       scanf("%d",&data1);       while(data1 != 0)       {           p = (Node *)malloc(sizeof(Node));           p -> data = data1;           p -> next = h;           h = p;           scanf("%d",&data1);       }       return h;   }      void Outputlist(Node *head)   {       Linklist p;       p = head;       while(p != NULL )       {           printf("%d ",p->data);           p = p->next;       }       printf("\n");   }      void Freelist(Node *head)   {       Node *p;       Node *q = NULL;       p = head;       while(p != NULL)       {           q = p;           p = p->next;           free(q);       }   }      int main()   {       Node *head;       head = Createlist();          Outputlist(head);          Freelist(head);          return 0;   }   2.顺序栈 [cpp] view plain copy #include <iostream>   #include <stdio.h>   #include <stdlib.h> ///顺序栈   #define MaxSize 100      using NAMESPACE std;      typedef

    标签: 数据结构 实验

    上传时间: 2018-05-09

    上传用户:123456..

  • 数据结构实验

    #include <iostream> #include <stdio.head> #include <stdlib.head> #include <string.head> #define ElemType int #define max 100 using NAMESPACE std; typedef struct node1 { ElemType data; struct node1 *next; }Node1,*LinkList;//链栈 typedef struct { ElemType *base; int top; }SqStack;//顺序栈 typedef struct node2 { ElemType data; struct node2 *next; }Node2,*LinkQueue; typedef struct node22 { LinkQueue front; LinkQueue rear; }*LinkList;//链队列 typedef struct { ElemType *base; int front,rear; }SqQueue;//顺序队列 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 //1.采用链式存储实现栈的初始化、入栈、出栈操作。 LinkList CreateStack()//创建栈 { LinkList top; top=NULL; return top; } bool StackEmpty(LinkList s)//判断栈是否为空,0代表空 { if(s==NULL) return 0; else return 1; } LinkList Pushead(LinkList s,int x)//入栈 { LinkList q,top=s; q=(LinkList)malloc(sizeof(Node1)); q->data=x; q->next=top; top=q; return top; } LinkList Pop(LinkList s,int &e)//出栈 { if(!StackEmpty(s)) { printf("栈为空。"); } else { e=s->data; LinkList p=s; s=s->next; free(p); } return s; } void DisplayStack(LinkList s)//遍历输出栈中元素 { if(!StackEmpty(s)) printf("栈为空。"); else { wheadile(s!=NULL) { cout<<s->data<<" "; s=s->next; } cout<<endl; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 //2.采用顺序存储实现栈的初始化、入栈、出栈操作。 int StackEmpty(int t)//判断栈S是否为空 { SqStack.top=t; if (SqStack.top==0) return 0; else return 1; } int InitStack() { SqStack.top=0; return SqStack.top; } int pushead(int t,int e) { SqStack.top=t; SqStack.base[++SqStack.top]=e; return SqStack.top; } int pop(int t,int *e)//出栈 { SqStack.top=t; if(!StackEmpty(SqStack.top)) { printf("栈为空."); return SqStack.top; } *e=SqStack.base[s.top]; SqStack.top--; return SqStack.top; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 //3.采用链式存储实现队列的初始化、入队、出队操作。 LinkList InitQueue()//创建 { LinkList head; head->rear=(LinkQueue)malloc(sizeof(Node)); head->front=head->rear; head->front->next=NULL; return head; } void deleteEle(LinkList head,int &e)//出队 { LinkQueue p; p=head->front->next; e=p->data; head->front->next=p->next; if(head->rear==p) head->rear=head->front; free(p); } void EnQueue(LinkList head,int e)//入队 { LinkQueue p=(LinkQueue)malloc(sizeof(Node)); p->data=e; p->next=NULL; head->rear->next=p; head->rear=p; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //4.采用顺序存储实现循环队列的初始化、入队、出队操作。 bool InitQueue(SqQueue &head)//创建队列 { head.data=(int *)malloc(sizeof(int)); head.front=head.rear=0; return 1; } bool EnQueue(SqQueue &head,int e)//入队 { if((head.rear+1)%MAXQSIZE==head.front) { printf("队列已满\n"); return 0; } head.data[head.rear]=e; head.rear=(head.rear+1)%MAXQSIZE; return 1; } int QueueLengthead(SqQueue &head)//返回队列长度 { return (head.rear-head.front+MAXQSIZE)%MAXQSIZE; } bool deleteEle(SqQueue &head,int &e)//出队 { if(head.front==head.rear) { cout<<"队列为空!"<<endl; return 0; } e=head.data[head.front]; head.front=(head.front+1)%MAXQSIZE; return 1; } int gethead(SqQueue head)//得到队列头元素 { return head.data[head.front]; } int QueueEmpty(SqQueue head)//判断队列是否为空 { if (head.front==head.rear) return 1; else return 0; } void travelQueue(SqQueue head)//遍历输出 { wheadile(head.front!=head.rear) { printf("%d ",head.data[head.front]); head.front=(head.front+1)%MAXQSIZE; } cout<<endl; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 //5.在主函数中设计一个简单的菜单,分别测试上述算法。 int main() { LinkList top=CreateStack(); int x; wheadile(scanf("%d",&x)!=-1) { top=Pushead(top,x); } int e; wheadile(StackEmpty(top)) { top=Pop(top,e); printf("%d ",e); }//以上是链栈的测试 int top=InitStack(); int x; wheadile(cin>>x) top=pushead(top,x); int e; wheadile(StackEmpty(top)) { top=pop(top,&e); printf("%d ",e); }//以上是顺序栈的测试 LinkList Q; Q=InitQueue(); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q,x); } int e; wheadile(Q) { deleteEle(Q,e); printf("%d ",e); }//以上是链队列的测试 SqQueue Q1; InitQueue(Q1); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q1,x); } int e; wheadile(QueueEmpty(Q1)) { deleteEle(Q1,e); printf("%d ",e); } return 0; }

    标签: 数据结构 实验

    上传时间: 2018-05-09

    上传用户:123456..

  • 道理特分解法

    #include "iostream" using NAMESPACE std; class Matrix { private: double** A; //矩阵A double *b; //向量b public: int size; Matrix(int ); ~Matrix(); friend double* Dooli(Matrix& ); void Input(); void Disp(); }; Matrix::Matrix(int x) { size=x; //为向量b分配空间并初始化为0 b=new double [x]; for(int j=0;j<x;j++) b[j]=0; //为向量A分配空间并初始化为0 A=new double* [x]; for(int i=0;i<x;i++) A[i]=new double [x]; for(int m=0;m<x;m++) for(int n=0;n<x;n++) A[m][n]=0; } Matrix::~Matrix() { cout<<"正在析构中~~~~"<<endl; delete b; for(int i=0;i<size;i++) delete A[i]; delete A; } void Matrix::Disp() { for(int i=0;i<size;i++) { for(int j=0;j<size;j++) cout<<A[i][j]<<" "; cout<<endl; } } void Matrix::Input() { cout<<"请输入A:"<<endl; for(int i=0;i<size;i++) for(int j=0;j<size;j++){ cout<<"第"<<i+1<<"行"<<"第"<<j+1<<"列:"<<endl; cin>>A[i][j]; } cout<<"请输入b:"<<endl; for(int j=0;j<size;j++){ cout<<"第"<<j+1<<"个:"<<endl; cin>>b[j]; } } double* Dooli(Matrix& A) { double *Xn=new double [A.size]; Matrix L(A.size),U(A.size); //分别求得U,L的第一行与第一列 for(int i=0;i<A.size;i++) U.A[0][i]=A.A[0][i]; for(int j=1;j<A.size;j++) L.A[j][0]=A.A[j][0]/U.A[0][0]; //分别求得U,L的第r行,第r列 double temp1=0,temp2=0; for(int r=1;r<A.size;r++){ //U for(int i=r;i<A.size;i++){ for(int k=0;k<r-1;k++) temp1=temp1+L.A[r][k]*U.A[k][i]; U.A[r][i]=A.A[r][i]-temp1; } //L for(int i=r+1;i<A.size;i++){ for(int k=0;k<r-1;k++) temp2=temp2+L.A[i][k]*U.A[k][r]; L.A[i][r]=(A.A[i][r]-temp2)/U.A[r][r]; } } cout<<"计算U得:"<<endl; U.Disp(); cout<<"计算L的:"<<endl; L.Disp(); double *Y=new double [A.size]; Y[0]=A.b[0]; for(int i=1;i<A.size;i++ ){ double temp3=0; for(int k=0;k<i-1;k++) temp3=temp3+L.A[i][k]*Y[k]; Y[i]=A.b[i]-temp3; } Xn[A.size-1]=Y[A.size-1]/U.A[A.size-1][A.size-1]; for(int i=A.size-1;i>=0;i--){ double temp4=0; for(int k=i+1;k<A.size;k++) temp4=temp4+U.A[i][k]*Xn[k]; Xn[i]=(Y[i]-temp4)/U.A[i][i]; } return Xn; } int main() { Matrix B(4); B.Input(); double *X; X=Dooli(B); cout<<"~~~~解得:"<<endl; for(int i=0;i<B.size;i++) cout<<"X["<<i<<"]:"<<X[i]<<" "; cout<<endl<<"呵呵呵呵呵"; return 0; } 

    标签: 道理特分解法

    上传时间: 2018-05-20

    上传用户:Aa123456789