1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
|
#include <iostream>
#include <cstdio>
#include <cstdlib>
int main () {
FILE *stream = fopen("plot.txt", "w");;
std::cout<<"Geben Sie eine Zahl n ein, die größer als 2 ist."<<::std::endl;
int n;
std::cout<<"Zahl n:";
std::cin>>n;
for (int z=2; z<=n; z++) { //die Schleife hat einen Inhalt, bei dir kam ein }
int i = z; //Initialisierung nicht in der inneren Schleife
int a = 0;
for (int pf=2; pf<=i; pf++) {
while (i%pf == 0) {
a++;
i/=pf;
}
}
fprintf(stream, "%d %d\n", z, a);
}
fclose(stream);
system("gnuplot -p -e \"plot 'plot.txt'\"");
return 0;
} |