Liczby całkowite w c++

0

Co trzeba zmienić w programie, aby wypluwał liczby całkowite? Wynikiem funkcji skala(5) powinno być 2, a wynikiem funkcji skala(52) liczba 10. Podczas gdy mi wychodzą wyniki: 2.5 i 10.3333.

#include <iostream>
using namespace std;
float skala(float v) {
	return (v + 10)/6;
}
int main() {
	cout << skala(5) <<endl;
	cout << skala(52) <<endl;
	return 0;
}
4

Jak chcesz by funkcja zwracała wartości całkowite to zamiast float skala(float v) int skala(float v)

0
#include <iostream>
#include <cmath>
using namespace std;

float scala(float LeftY,float RightY,float LeftX,float RightX,float x)
{
	return (RightY*(x-LeftX)-LeftY*(x-RightX))/(RightX-LeftX);
}

int main()
{
	for(int i=5;i<=52;i+=4) cout<<i<<" => "<<scala(2,10,5,52,i)<<" => "<<round(scala(2,10,5,52,i))<<endl;
	cout<<52<<" => "<<scala(2,10,5,52,52)<<" => "<<round(scala(2,10,5,52,52))<<endl;
	cout<<endl;
	for(int i=2;i<=10;++i) cout<<i<<" => "<<scala(5,52,2,10,i)<<endl;
    return 0;
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1