Помогите пожалуйста перевести код с C++ на С ======================================
#include<iostream>
#include<cstdio>
#include<fstream>
using namespace std;
int number_of_deeds;
struct deed {
int deed_id;
char deed_name[55];
int points_for_deed;
int total_times_done;
int total_points_earned;
};
inline bool cmptask1(deed a, deed b)
{
return a.total_times_done > b.total_times_done;
}
inline bool cmptask2(deed a, deed b)
{
return a.total_points_earned > b.total_points_earned;
}
inline bool cmptask5(deed a, deed b)
{
return a.deed_name < b.deed_name;
}
int main() {
ifstream in("deed_list.txt");
in >> number_of_deeds;
deed *deed_list = new deed[number_of_deeds];
for(int i = 0; i < number_of_deeds; ++i)
{
in >> deed_list[i].deed_id;
in >> deed_list[i].deed_name;
in >> deed_list[i].points_for_deed;
}
in.close();
ifstream fin("daylog.txt");
int id, times;
while(fin >> id >> times)
{
for(int i = 0; i < number_of_deeds; ++i)
if(deed_list[i].deed_id == id)
deed_list[i].total_times_done += times;
}
for(int i = 0; i < number_of_deeds; ++i)
deed_list[i].total_points_earned = deed_list[i].total_times_done *
deed_list[i].points_for_deed;
// TASK1 :
sort(deed_list, deed_list + number_of_deeds, cmptask1);
printf("task1 : after sort by deeds_total_times_done:\n\n\n");
/*for(int i = 0; i < number_of_deeds; ++i)
if(deed_list[i].total_times_done > 0)
;
vivod;
vivod task1;
*/
sort(deed_list, deed_list + number_of_deeds, cmptask2);
//vivod task2
//TASK 3 :
int total = 0;
for(int i=0;i<number_of_deeds;i++) {
total += deed_list[i].total_times_done;
}
printf("TASK 3\n\n");
printf("total number of deeds is %i", total);
printf("\n\n");
//TASK 4 :
total = 0;
for (int i=0; i<number_of_deeds; i++) {
total += deed_list[i].total_points_earned;
}
printf ("TASK 4\n\n");
printf("total number of deed points is %i", total);
sort(deed_list, deed_list + number_of_deeds, cmptask5);
//vivod task5;
char name[55];
scanf("%s", name);
int l = 0, r = number_of_deeds;
while(l + 1 < r)
{
int m = l + r >> 1;
if(deed_list[m].deed_name <= name)
l = m;
else
r = m;
}
//vivod task6
if(deed_list[l].deed_name == name); //deed_information output
else printf("No such deed");
}
======================================
c
https://ru.stackoverflow.com/q/594817