Facebook
From Crimson Macaque, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 242
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. void warunki_poczatkowe(){
  7.         double x[20];           //Zbiór liczb
  8.         double y[20];
  9.         double u[20];
  10.        
  11.         double h = 0.1;         // h
  12.        
  13.         x[0] = 0;                       // Warunki początkwe
  14.         y[0] = -1;
  15.         u[0] = 1;
  16.        
  17.         printf("X = %f \t Y = %f \t U = %f \n", x[0], y[0], u[0]);      // Wypisuje warunki początkowe
  18.         for(int i = 1; i <= 20; i++){
  19.                 x[i] = x[i-1] + h;                                              // Iteruje x;
  20.                 y[i] = y[i-1] + h*u[i-1];                                       // Iteruje y;
  21.                 u[i] = u[i-1] + h*(1 - x[i-1] + y[i-1]);                                // Iteruje u;
  22.                 printf("X[%d] = %f \t Y[%d] = %f \t U[%d] = %f \n", i, i, i, x[i], y[i], u[i]);     // Wyspiuje iteracje
  23.         }
  24. }
  25.  
  26. int main() {
  27.         double x[20];
  28.         double y[20];
  29.         double u[20];
  30.         double s[20];
  31.        
  32.         double h = 0.1;
  33.        
  34.         x[0] = 0;
  35.         y[0] = -1;
  36.         y[20] = 1;
  37.        
  38.         printf("Podaj strzal u[0]");
  39.         cin >> u[0] >> u[1];
  40.         printf("Podaj strzal s[0] oraz s[1]");
  41.         cin >> s[0] >> s[1];
  42.        
  43.        
  44.        
  45.         system("PAUSE");
  46.         return 0;
  47. }