pole10
#include <iostream> using namespace std; const int N= 10; int a[N]; void tisk (int p[N]) { for (int j=0; j<N; j++) { cout << "p[" << j << "]=" << p[j] << endl; } } int main() { a[0]=1; for (int i=1; i<N; i++) { // a[i]= 2 * a[i-1]; // mocniny 2 a[i]= i * a[i-1]; // faktorialy } tisk (a); cout << "KONEC" << endl; return 0; }
#include <iostream> using namespace std; const int N= 10; int a[N]; void tisk (int p[N], int k) { for (int j=0; j<k; j++) { cout << p[j] << " "; } cout<< endl; } int main() { a[0]=1; tisk (a, 1); for (int k=1; k<=N-1; k++) { int b [N]; b[0]=1; for (int i=1; i<= k-1; i++) { b[i]=a[i]+a[i-1]; } b[k]= 1; tisk (b, k+1); for (int i=0; i<=k; i++) { a[i]=b[i]; } } cout << "KONEC" << endl; return 0; }
#include <iostream> using namespace std; const int N= 10; int a[N][N]; void tisk (int p[N], int k) { for (int j=0; j<k; j++) { cout << p[j] << " "; } cout<< endl; } int komb (int n, int k) { if (k == 0 || k == n || n == 0) return 1; else return komb (n-1, k-1) + komb (n-1, k); } int main() { for (int i = 0; i < N; i++) { for (int k = 0; k <= i; k++) { cout << komb (i, k) << " "; } cout << endl; } for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) a[i][j] = 0; a[0][0]= 1; tisk (a[0], 1); for (int k=1; k<=N-1; k++) { a[k][0]= 1; for (int i=1; i<= k-1; i++) { a[k][i]=a[k-1][i]+a[k-1][i-1]; } a[k][k]= 1; tisk (a[k], k+1); } cout << "KONEC" << endl; return 0; }
#include <iostream> using namespace std; const int N = 10; int a[N]; void tisk (int p[N], int k) { for (int j=0; j<k; j++) { cout << p[j] << " "; } cout<< endl; } int main() { for (int i = 0; i < N; i++) a[i] = 0; int v = 30; // cislo, ktere budeme prevadet int k = 0; // index, 2 ^ k while ( v>0 && k< N) { a[k] = v % 10; v /= 10; k++; } for (int i=N-1; i>=0; i--) cout << a[i] << " "; cout << "Konec" << endl; return 0; }
pole10.txt · Last modified: 2018/10/18 15:05 by 127.0.0.1