fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. int total_colonies = 300; // Всего колоний
  5. int target_colonies = 45; // Колонии с белком
  6.  
  7. // Чтобы не потерять точность, приводим один из int к double при делении
  8. // Умножаем на 100.0 для получения процентов
  9. double percentage = (static_cast<double>(target_colonies) / total_colonies) * 100.0;
  10.  
  11. std::cout << "Всего колоний: " << total_colonies << std::endl;
  12. std::cout << "Колоний с белком: " << target_colonies << std::endl;
  13. std::cout << "Процент колоний с белком: " << percentage << "%" << std::endl;
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Всего колоний: 300
Колоний с белком: 45
Процент колоний с белком: 15%