Advertisement
brsjak

Generiranje niza - SP Lab 4

Oct 25th, 2016
911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include <stdio.h>
  2.     int main(){
  3.     int n, i;
  4.     scanf("%d", &n);
  5.     float sum=0, a, b, niza[n];
  6.     scanf("%f%f", &a, &b);
  7.     niza[0]=a;
  8.     niza[1]=b;
  9.     sum=a+b;
  10.     for(i=2;i<n;i++){
  11.         niza[i]=sum/2;
  12.         sum+=niza[i];
  13.     }
  14.     for(i=0;i<n;i++){
  15.         printf("%.2f ",niza[i]);
  16.     }
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement