00001
00002
00003
00004
00005
00006
00007
00008 #include "dyn.h"
00009
00010 typedef struct {real radius;
00011 real mass;} rm;
00012
00013 int comp(rm *a, rm* b)
00014 {
00015 if (a->radius < b->radius)
00016 return -1;
00017 else if (a->radius > b->radius)
00018 return 1;
00019 else
00020 return 0;
00021 }
00022
00023 main(int argc, char ** argv)
00024 {
00025 extern char *poptarg;
00026 int c;
00027 char* param_string = "c";
00028
00029 while ((c = pgetopt(argc, argv, "param_string")) != -1)
00030 switch(c) {
00031
00032 case 'c': break;
00033 case '?': params_to_usage(cerr, argv[0], param_string);
00034 exit(1);
00035 }
00036
00037 dyn *b;
00038
00039 while (b = get_dyn(cin)) {
00040
00041 real msum = 0;
00042 int i = 0, n = 0;
00043
00044 b->to_com();
00045
00046 for_all_daughters(dyn, b, bb) n++;
00047
00048 rm *sys = new rm[n];
00049
00050 for_all_daughters(dyn, b, bb) {
00051
00052 sys[i].radius = bb->get_pos()*bb->get_pos();
00053 sys[i].mass = bb->get_mass();
00054
00055 i++;
00056 }
00057
00058 qsort(sys, (size_t) n, (size_t) sizeof(rm), comp);
00059
00060 for (i = 0; i < n; i++) {
00061 msum += sys[i].mass;
00062 cerr << i << " " << sqrt(sys[i].radius) << " " << msum << endl;
00063 }
00064
00065 rmtree(b);
00066 }
00067 }
00068