链队列的实现
摘要://h1.h#includetypedef char QElemType; typedef void Status;using namespace std;typedef struct QNode{QElemType data;struct QNode *next;}*QueuePtr;typedef struct{QueuePtr front;//队头指针QueuePtr rear;//队尾指针}LinkQueue;//function.h#include"h1.h" using namespace std;LinkQueue InitQueue() //构建一个空队列Q
阅读全文
posted @
2014-03-02 14:53
琥珀玲珑
阅读(384)
推荐(0)
用流对象的成员函数控制输出格式
摘要:#includeusing namespace std;int main(){ int a;cout>a; //cout.setf(ios::unitbuf); //每次输出之后刷新所有的流 //cout.setf(ios::stdio); //每次输出之后清除stdout,stderr cout.setf(ios::showbase); //设置输出时的基数符号(八进制以0打头,十六进制以0x打头)cout>b; cout.setf(ios::uppercase); //以十六进制输出字母时以大写字母表示 cout.setf(ios::hex);cout<<"
阅读全文
posted @
2013-08-06 18:13
琥珀玲珑
阅读(317)
推荐(0)
共同体类型,学生,教师
摘要:#includestruct //声明无名结构体类型{int num; //编名char name[10]; //姓名char sex; //性别char job; //职业union //声明无名共同体类型{int clas; //班级char position[10]; //职务}category; //共同体变量}person[2]; //定义结构体数组,有两个元素int main(){int i;for(i=0;i<2;i++){printf("please enter the data of person:\n");scanf("%d %s %c
阅读全文
posted @
2013-07-05 13:10
琥珀玲珑
阅读(331)
推荐(0)
五种颜色的球若干个,从中取三个球,三球颜色不同的组合。
摘要:#includeint main(){enum Color{red,yellow,blue,white,black}; //声明枚举类型enum Colorenum Color i,j,k,pri; //定义枚举变量i,j,k,priint n,loop;n=0;for(i=red;i<=black;i++)for(j=red;j<=black;j++)if(i!=j){for(k=red;k<=black;k++)if((k!=i)&&(k!=j)){n++; //符合条件加1 printf("%-4d",n); //输出第几个符合条件的
阅读全文
posted @
2013-07-05 12:03
琥珀玲珑
阅读(740)
推荐(0)
使用控制符控制输出格式
摘要:iomainip 控制符#include#includeusing namespace std;int main(){int a;cout>a;cout>b;cout<<"16进制:"<<setiosflags(ios::uppercase)<<setbase(16)<<b<<endl; //输出a的16进制,输出字母X时以大写表示double pi=22.0/7.0;cout<<setiosflags(ios::scientific)<<setprecision(8); //用
阅读全文
posted @
2013-07-02 12:07
琥珀玲珑
阅读(305)
推荐(0)