Vous êtes sur la page 1sur 8

54) #include <iostream>

#include <fstream>
using namespace std;
ofstream f("numere.txt");
int main()
{
int a, b, x, i,c, ok;
cin >> a >>b;
i=a;
while (i<=b)
{x=i;
ok=0;
while (x>9&&ok==0)
{c=x%10;
x=x/10;
if (c!=x%10)
ok=1;
}
if (ok==0)
f<<i<< " " ;
i++;}
return 0;
f.close();
}


56) #include <iostream>
using namespace std;
int main()
{ int x, c, ap;
cin>>c;
cin>>x;
while (x!=0)
{ap=0;
while (x>0)
{if (x%10==c)
ap++;
x=x/10;}
cout<< ap<< endl;
cin>>x;
}
}
58) #include <iostream>
#include <fstream>
using namespace std;
ifstream f("matrice.txt");
int main ()
{
int n, a[10][10], i, j, ok;
f>>n;
for (i=1; i<=n; i++)
for (j=1; j<=n; j++)
f>> a[i][j];
ok=0;
for (i=1; i<=n; i++)
for (j=1; j<=n; j++)
if (a[i][j]!=a[j][i])
ok=1;
if (ok==0)
cout<< "simetrica";
else
cout<<"nesimetrica";
f.close();
}

59) #include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream f("sir.in");
ofstream g("sir.out");
int prim(int x)
{int d, ok;
if (x<=1)
ok=0;
else
{ok=1;
for (d=2; d<=sqrt(x); d++)
if (x%d==0)
ok=0;
}
return ok;
}
int main()
{int x;
f>>x;
while (!f.eof())
{if (prim(x)==1)
g<<x<<" ";
f>>x;
}
f.close();
g.close();
}


72) #include <iostream>
#include <fstream>
using namespace std;
ifstream f("2.txt");
ifstream g("1.txt");
int main()
{ int x, a[50],i;
g>>x;
i=0;
while (!g.eof())
{i++;
a[i]=x;
g>>x;
}
f>>x;
while (!f.eof())
{i++;
a[i]=x;
f>>x;
}
g.close();
ofstream g("1.txt");
for (x=1; x<=i; x++)
g << a[x] << " ";
f.close();
g.close();
}


73#include<iostream>
#include<fstream> using namespace std;
ifstream f("numere.txt");
ofstream g("pare.txt");
int main()
{int x;
f>>x;
while (!f.eof())
{if (x%2==0) g<<x<<endl;
f>>x; }
f.close();
g.close(); }
9 #include <iostream>
#include<stdio.h>
#include<string.h> using namespace std;
int main()
{char s[20], c, d; int i;
cout<< "dati cuvantul";
gets(s);
cout<< "dati litera";
c=getchar();
for (i=0; i<strlen(s); i++) {d=s[i];
s[i]=c;
puts(s); s[i]=d;} }
19 x
n

#include<iostream.h>
Int n,x;
Intf(int i);
{if (i<=n)
Return x *putere()i+1;
Else
Return 1;
}
Int main()
{cout <<x=; cin>>x;
Cout <<n=; cin>>n;
Cout<<putere (1);
}

20 NUMERE.TXT
#include<iostream.h>
#include <fstream.h>
Fstream f(NUMERE.TXT
Int cmmdc (int a, int b)
{int r;
While (b>0)
{r=a%b;
A=b;
B=r;
}
Return a;
}
Int main ()
{int v[30], n, i,x;
f>>n;
for (i=1; i<=n; i++)
f>>v[i]
x=cmmdc (v[1], v[2]);
for (i=3, i<=n, i++)
x=cmmdc (x, v[i]);
cout<<x;
}
44 toate numerele natural de cinci cifre
#include<iostream.h>
Int main()
{int s,p,c;
Long n;
For (n=10 000, n<=99 999; n++)
{s=0
P=1;
While (n>0)
{c=n%10;
S=s+c;
P=p*c;
N=n/10;
}
If (p%s==0)
Cout<<n<< ;
}
}
10 Elemente deasupra diagonalei
#include<iostream.h>
#include <math.h>
Int n;
Int prim (int x)
{int d, OK;
If (x<=1)
OK=0;
Else
{OK=1;
For (d=2, d<=sqrt (x), d++)
If (x%d==0)
OK=0;
}
Return OK;
}
int main()
{int a[20][20], i, j, nr;
Nr=0;
Cout<<n=;c in>>n;
For (i=1, i<=n, i++)
For (j=1,j<=n, j++)
{cout <<a[<<i<<][<<j<<]=;
Cin>>a[i][j];
}
For (i=1, i<=n-1,i++)
For (j=i+1,j<=n,j++)
If (prim (a[i][j])
Nr++;
Cout << nr;
}

Vous aimerez peut-être aussi