首页 > 其他分享 >daka

daka

时间:2023-05-20 22:12:49浏览次数:26  
标签:daka weight out1 ios in1 Dog dog2

#include<bits/stdc++.h>

using namespace std;

class Dog
{
public: 
    int age;
    double weight;
    Dog(int a, double b): age(a) , weight(b) {
    }
    Dog() {
    }
 } ;
 
 int main()
 {
     Dog dog1(10, 5);
     Dog dog2;
     /*ofstream out1("dog.txt", ios::out);
     out1 << dog1.age << " " << dog1.weight ;
     out1.close();
     
     ifstream in1("dog.txt", ios::in);
     in1 >> dog2.age >> dog2.weight;
     in1.close();
     */
     ofstream out1("dog.dat", ios::out | ios::binary);
     out1.write((char*)(&dog1), sizeof(dog1));
     out1.close();
    
    ifstream in1("dog.dat", ios::in | ios::binary);
    in1.read((char*)(&dog2), sizeof(dog2));
    in1.close();
     
     
     cout << dog2.age << " " << dog2.weight;
 }

 

标签:daka,weight,out1,ios,in1,Dog,dog2
From: https://www.cnblogs.com/kongxiangzeng/p/17417892.html

相关文章

  • daka
    #include<bits/stdc++.h>usingnamespacestd;classDog{public:intage;doubleweight;Dog(inta,doubleb):age(a),weight(b){}Dog(){}};intmain(){Dogdog1(10,5);Dogdog2;ofstreamout1(......
  • daka
    #include<iostream>#include<string>#include<fstream>#include<sstream>#include<bits/stdc++.h>usingnamespacestd;structServerInfo{char_ip[32];int_port;};structConfigManager{public:......
  • daka :p
    6-2数组排序输出(函数模板)分数 10全屏浏览题目切换布局作者 何振峰单位 福州大学对于输入的每一批数,按从小到大排序后输出。一行输入为一批数,第一个输入为数据类型(1表示整数,2表示字符型数,3表示有一位小数的浮点数,4表示字符串,0表示输入结束),第二个......
  • daka :p
     2.设计思路①依次列举出所有0~9的两位相同数字②在第一步的前提下依次列举出0~9的两位相同数字③将第一第二步中的四个数字组成的数进行开根,判断结果是否为整数后输出结果 #include<bits/stdc++.h>usingnamespacestd;intmain(){inti,j,k,temp;for......
  • daka :p
      #include<bits/stdc++.h>#defineN10usingnamespacestd;main(){inti,j,a[N],t,count=0;printf("ÇëΪÊý×éÔªËظ³³õÖµ£º\n");for(i=0;i<N;i++)scanf("%d",&a[i]);for(i=1;i<=N-1;i++)......
  • daka :p
    #incldude<bits/stdc++.h>usinggnamespacestd;intmain(){inti,j,x,flag=0;for(i=23;flag==0;i++){for(j=1,x=i;j<=4&&x>=11;j++){if((x+1)%(j+1)==0)x-=......
  • daka :p
     #include<bits/stdc++.h>usingnamespacestd;intmain(){intm,n,number=0;for(m=0;m<=3;m++){for(n=0;n<=3;n++){if(8-m-n<=6)number++;}}cout<<......
  • daka :p
    复数类Complex有两个数据成员:a和b,分别代表复数的实部和虚部,并有若干构造函数和一个重载-(减号,用于计算两个复数的距离)的成员函数。要求设计一个函数模板template<classT>doubledist(Ta,Tb)对int,float,Complex或者其他类型的数据,返回两个数据的间距。以上类名和函数模......
  • daka :p
     #include<bits/stdc++.h>usingnamespacestd;voidprint(ints[]);intjudge(intc[]);intj=0;intmain(){ intsweet[10]={10,2,8,22,16,4,10,6,14,20}; inti,t[10],l; printf("child12345678910\n"); printf......