I code a program to calculate all possibilities, but with integers and now I have to do it for floats, how can I change the program to input floats instead of integers? This is just a part but if I can do it for the fist switch I can do it for all:
#include <fstream>
using namespace std;
ifstream in("multimi.in");
ofstream out("produs.out");
void input(int *v)
{
for(int i=1; i<=2; i++)
in>>v[i];
}
int main()
{
float a[3],b[3],c[3],d[3],e[3],s[3];
int num_tot;
in>>num_tot;
switch(num_tot)
{
case 2:
input(a);
input(b);
for(int i=1; i<=2; i++)
for(int j=1; j<=2; j++)
out<<a[i]<<","<<b[j]<<endl;
break;
This is the code with int which works:
#include <fstream>
using namespace std;
ifstream in("multimi.in");
ofstream out("produs.out");
void input(int *v)
{
for(int i=1; i<=2; i++)
in>>v[i];
}
int main()
{
int a[3],b[3],c[3],d[3],e[3],s[3];
int num_tot;
in>>num_tot;
switch(num_tot)
{
case 2:
input(a);
input(b);
for(int i=1; i<=2; i++)
for(int j=1; j<=2; j++)
out<<a[i]<<","<<b[j]<<endl;
break;