poniedziałek, 20 grudnia 2021

Mars oposition (example C++)

 #include <iostream>

#include <fstream>

#define mtime 7

using namespace std;


struct MARS

{

double angular_DIAM;

double distance_UA;

double distance_MLN;

string date;

};


int main(int argc, char **argv)

{

struct MARS *mars_OPOSITION=new struct MARS[mtime];

mars_OPOSITION[0].angular_DIAM=16.9;

mars_OPOSITION[0].distance_UA=0.550;

mars_OPOSITION[0].distance_MLN=82.3;

mars_OPOSITION[0].date="2022.12.08";

mars_OPOSITION[1].angular_DIAM=14.4;

mars_OPOSITION[1].distance_UA=0.643;

mars_OPOSITION[1].distance_MLN=96.2;

mars_OPOSITION[1].date="2025.01.16";

mars_OPOSITION[2].angular_DIAM=13.8;

mars_OPOSITION[2].distance_UA=0.678;

mars_OPOSITION[2].distance_MLN=101.4;

mars_OPOSITION[2].date="2027.02.19";

mars_OPOSITION[3].angular_DIAM=14.4;

mars_OPOSITION[3].distance_UA=0.649;

mars_OPOSITION[3].distance_MLN=97.1;

mars_OPOSITION[3].date="2029.03.25";

mars_OPOSITION[4].angular_DIAM=16.9;

mars_OPOSITION[4].distance_UA=0.559;

mars_OPOSITION[4].distance_MLN=83.6;

mars_OPOSITION[4].date="2031.05.04";

mars_OPOSITION[5].angular_DIAM=22.00;

mars_OPOSITION[5].distance_UA=0.427;

mars_OPOSITION[5].distance_MLN=63.9;

mars_OPOSITION[5].date="2033.06.27";

mars_OPOSITION[6].angular_DIAM=24.5;

mars_OPOSITION[6].distance_UA=0.382;

mars_OPOSITION[6].distance_MLN=57.1;

mars_OPOSITION[6].date="2035.09.15";

fstream m_FILE( "MARS.txt", ios::out );

if(m_FILE.good())

{

for(int i=0;i<mtime;i++)

{

m_FILE<<mars_OPOSITION[i].angular_DIAM<<" ";

m_FILE<<mars_OPOSITION[i].distance_UA<<" ";

m_FILE<<mars_OPOSITION[i].distance_MLN<<" ";

m_FILE<<mars_OPOSITION[i].date<<"\n";

m_FILE.flush();

}

m_FILE.close();

}

delete [] mars_OPOSITION;

return 0;

}