Cod sursa(job #772716)

Utilizator buckyBalu Cristian bucky Data 30 iulie 2012 16:29:04
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <iostream>
#include <fstream>

using namespace std;

int n,ok,solutie = 0;

int verificare(int a,int b)
{
    if(a%b!=0 && b%a!=0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int main()
{
    ifstream f("fractii.in");
    ofstream g;
    g.open("fractii.out");
    f >> n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            g << i << " " << j << " " << ok << "\n";
            if(i!=j)
            {
                ok=0;
                ok= verificare(i,j);
                if(ok==1)
                {
                    solutie++;
                }
            }
            if(i==1 || j==1)
            {
                solutie++;
            }
        }
    }
    g << solutie;
    g.close();
    return 0;
}