Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <clocale>
  3. using namespace std;
  4.  
  5. const int N = 10;
  6.  
  7. void generate(double *mas){ //Функция генерации массива
  8. mas[0] = 0.0;
  9. for(int i=1; i<N; i++){
  10. mas[i] = mas[i-1]+i*pow(10, -i);
  11. }
  12. }
  13.  
  14. void print(double *mas){ //Функция вывода
  15. cout.precision(10); //Округление до 10 знаков максимум
  16. for(int i=0; i<N; i++){
  17. cout << mas[i] << endl;
  18. }
  19. }
  20.  
  21. int main(void){
  22. double mas[N]; //Сам массив
  23. setlocale(LC_ALL,"RUSSIAN"); //Русская кодировка
  24. generate(mas); //Генерируем
  25. print(mas); //Выводим
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement