Ajutor va rog! Mulțumesc anticipat!
Răspunsuri la întrebare
1.
#include<fstream>
#include<iostream>
using namespace std;
int main(){
int n,x,s=0,k=0;
ifstream f("unu.in");
f>>n;
for(int i=1;i<=n;i++)
f>>x,if(x%2==1) k++,s+=x;
f.close();
cout<<(float)s/k;
return 0;
}
2.
#include<iostream>
using namespace std;
int main(){
int x[101],m,max,min,nr=0;
cin>>m;
cin>>x[1];
min=max=x[1];
for(int i=2;i<=m;i++){
cin>>x[i];
if(x[i]>max)
max=x[i];
if(x[i]<min)
min=x[i];
int k=0;
for(int d=1;d<=x[i];d++)
if(x[i]%d==0)
k++;
if(k==2)
nr++;
}
cout<<max<<' '<<min<<' '<<nr;
return 0;
}
3.
#include<iostream>
using namespace std;
int main() {
int m[101][101], n;
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
if (j < n - i + 1)
m[i][j] = 0;
if (j == n - i + 1)
m[i][j] = j + i;
if (j > n - i + 1)
if (i < j) m[i][j] = i;
else m[i][j] = j;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++)
cout << m[i][j] << ' ';
cout << endl;
}
return 0;
}