#include <stdlib.h>
float raise(float n, int times)
{
float result = n;
int i;
if(times < 1) return 1;
if(times < 2) return n;
for(i = 1; i < times; ++i) result *= n;
return result;
}
float my_round(float n, int places)
{
float x = raise(10, places);
n *= x;
n += 0.5;
return ((int)n)/x;
}
int main()
{
float n = 1000.0/7.0;
printf("%f\n", my_round(n, 3));
printf("%f\n", my_round(n, 2));
printf("%f\n", my_round(n, 1));
printf("%f\n", my_round(n, 0));
return EXIT_SUCCESS;
}