上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页

2018年6月29日

摘要: 1 //设计一个简单的动态数组类 2 #include 3 #include 4 class Array{ 5 private: 6 double *arr; 7 int size; 8 public: 9 Array(int sz=100); 10 ~Array(); 11 }; 12 13 A... 阅读全文
posted @ 2018-06-29 18:34 孙悟空son_ku_kong 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1 //用类实现复数的加减功能 2 #include 3 class Complex{ 4 private: 5 float real;//虚部 6 float img;//实部 7 public: 8 Complex(float real,float img){ 9 this->real=... 阅读全文
posted @ 2018-06-29 18:29 孙悟空son_ku_kong 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1 //利用动态数组保存字符串"Data Structure"程序 2 #include 3 int main(){ 4 char *str,s[]="Data Structure"; 5 int length=14;//字符串的长度 6 str=new char[sizeof(s)+1]; 7 int i; 8 for(i=0;i<len... 阅读全文
posted @ 2018-06-29 15:11 孙悟空son_ku_kong 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 1 //命名空间的使用 2 #include 3 namespace module{ 4 void f1(){ 5 cout<<"这是f1()函数"<<endl; 6 } 7 void f2(){ 8 cout<<"这是f2()函数"<<endl; 9 } 10 double s=1.0; 11 } 12 ... 阅读全文
posted @ 2018-06-29 15:06 孙悟空son_ku_kong 阅读(133) 评论(0) 推荐(0) 编辑

2018年6月28日

摘要: 1 //编写个人通讯录管理系统,实现以下功能 2 //1.管理系统提供菜单 3 //2.将通讯录存入文件中,并且命名为PersonInfo.txt 4 //3.管理系统将执行以下操作 5 //(1)查看通讯录的所有信息 6 //(2)输入要查找的姓名,查找通讯录,如果找到则显示相关信息 7 //(3 阅读全文
posted @ 2018-06-28 17:47 孙悟空son_ku_kong 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 1 //ferror函数的作用是检查文件中是否有错误,如果有错,则返回非0,否则返回0 2 //ferror(文件指针) 3 #include 4 #include 5 int main(){ 6 FILE *fp; 7 if((fp=fopen("file_data.txt","r"))==NULL){ 8 printf("打开文件失败\n");... 阅读全文
posted @ 2018-06-28 17:46 孙悟空son_ku_kong 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 1 //feof函数的作用是判断文件指针是否在文件末尾,如果在文件末尾,返回非0,否则返回0 2 //feof(文件指针) 3 #include<stdio.h> 4 #include<stdlib.h> 5 int main(){ 6 FILE *fp; 7 char c; 8 if((fp=fo 阅读全文
posted @ 2018-06-28 17:45 孙悟空son_ku_kong 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1 //ftell函数的作用是返回文件位置指针的位置,给出当前位置指针相对于文件头的字节数 2 //返回值为long,当函数调用出错时,函数返回-1L 3 //ftell(文件指针) 4 #include 5 #include 6 int main(){ 7 FILE *fp; 8 long i; 9 if((fp=fopen("file_data.tx... 阅读全文
posted @ 2018-06-28 17:44 孙悟空son_ku_kong 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 //fseek函数的作用是将文件的位置指针移到指定位置 2 //fseek(文件指针,位移量,起始点) 3 #include 4 #include 5 int main(){ 6 FILE *fp; 7 char s[]="abcdefghijklmnopqrstuvwxyz"; 8 char c; 9 if((fp=fopen("file_... 阅读全文
posted @ 2018-06-28 17:43 孙悟空son_ku_kong 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 //rewind函数的作用是使位置指针重新返回指定文件的开头 2 #include 3 #include 4 int main(){ 5 FILE *fp; 6 char s[]="abcdefghijklmnopqrstuvwxyz"; 7 char c; 8 if((fp=fopen("file_data.txt","w+"))==NULL... 阅读全文
posted @ 2018-06-28 17:42 孙悟空son_ku_kong 阅读(193) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页

导航