mardi 1 septembre 2015

Dots in printf in C++

I encountered this snippet but couldn't understand how it works, especially the printf statements. Can someone explain

void remove_trailing_zeroes()
{
    int a,b; 
    bool f1,f2;
    f1=a%2;
    f2=b%2;
    if (f1==f2) {
        printf("%.0lf\n",(a*1.+b)/2.);
    }
    else {
        printf("%.1lf\n",(a*1.+b)/2.);
    }

}

EDIT: I have rephrased my question, help me improve it

Aucun commentaire:

Enregistrer un commentaire