55 lines
899 B
C++
55 lines
899 B
C++
//najdi 100 praštevil od 500 naprej
|
|
//izracunaj povprecje
|
|
//izpisi on najvisje do najnizje
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
void izpis (int polje[], int x){
|
|
x--;
|
|
for(x; x>=0; x--){
|
|
cout << polje[x]<<endl;
|
|
}
|
|
return;
|
|
}
|
|
|
|
int stevilo(int x){
|
|
int del;
|
|
x++;
|
|
for(x; x>0; x++){
|
|
del = 0;
|
|
for(int i=2; i<x; i++){
|
|
if(x%i==0){del=i;}
|
|
}
|
|
if(del==0){return x;}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
double povprecje(int polje[], int x){
|
|
double s = 0;
|
|
for(int i=0;i<x;i++){
|
|
s = s+polje[i];
|
|
}
|
|
double p = s/x;
|
|
return p;
|
|
}
|
|
|
|
int main(){
|
|
int velikost = 100;
|
|
int polje[velikost];
|
|
int r = 500;
|
|
double pov;
|
|
for(int i = 0;i<velikost;i++){
|
|
r=stevilo(r);
|
|
polje[i]=r;
|
|
}
|
|
|
|
// pov = povprecje(polje,velikost);
|
|
// cout << pov << endl;
|
|
|
|
izpis(polje, velikost);
|
|
|
|
return 0;
|
|
}
|