Rozwiązania¶
Zadanie 1¶
Zadanie 2¶
Zadanie 3¶
Zadanie 4¶
```cpp linenums="1"
include ¶
include ¶
using namespace std;
int main() { ifstream file("dates.txt"); int a, b, c, month; int months_count[13] = {}; for(int i = 0; i < 1000; i++) { file >> a >> b >> c; month = min(a, min(b, c)); months_count[month]++; }
file.close();
for(int i = 1; i <= 12; i++) {
cout << i << ": " << months_count[i] << endl;
}
return 0;
}
Zadanie 5¶
```cpp linenums="1"
include ¶
include ¶
using namespace std;
int main() { ifstream file("dates.txt"); int a, b, c, current_year, previous_year, result = 0; int current_length = 1, max_length = 1, current_start_year, max_start_year, max_end_year; file >> a >> b >> c; current_year = max(a, max(b, c)); current_start_year = current_year; max_start_year = current_year; max_end_year = current_year; for(int i = 1; i < 1000; i++) { previous_year = current_year; file >> a >> b >> c; current_year = max(a, max(b, c)); if(current_year > previous_year) { current_length += 1; if(current_length > max_length) { max_length = current_length; max_start_year = current_start_year; max_end_year = current_year; } } else { current_start_year = current_year; current_length = 1; } }
file.close();
cout << "Dlugosc: " << max_length << endl;
cout << "Rok startowy: " << max_start_year << endl;
cout << "Rok koncowy: " << max_end_year << endl;
return 0;
}