Pagini recente » Cod sursa (job #1555620) | Cod sursa (job #2145254) | Cod sursa (job #1411996) | Cod sursa (job #36075) | Cod sursa (job #110001)
Cod sursa(job #110001)
#include<fstream>
using namespace std;
int n,a[1000],p;
int prime(int x,int y)
{
while(x!=y)
{
if(x > y)
x = x-y;
if(y > x)
y = y-x;
}
if(y == 1) return 1;
else return 0;
}
int main()
{
ifstream fin("pairs.in");
ofstream fout("pairs.out");
int i,j;
fin>>n;
for(i = 1; i <= n; i++)
fin>>a[i];
for(i = 1; i <= n; i++)
{
for(j = i+1; j < n; j++)
if(prime(a[i],a[j]) == 1)
p++;
}
fout<<p;
fin.close();
fout.close();
}