Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define MAX_DIM 50
- #define LIMIT 0
- using namespace std;
- void derive (float data[], int dim, float diff[]);
- int main()
- {
- float data[MAX_DIM], diff[MAX_DIM];
- int dim;
- cin >> dim;
- while (dim <= LIMIT || dim > MAX_DIM)
- {
- cout << "Errore." << endl;
- cin >> dim;
- }
- derive(data, dim, diff);
- return 0;
- }
- void derive (float data[], int dim, float diff[])
- {
- for(int i = 0; i < dim; i++)
- {
- cout << "Elemento " << i+1 << ": ";
- cin >> data[i];
- }
- cout << ">-----------------------------------------<" << endl;
- for(int i = 1; i < dim; i++)
- {
- diff[i-1] = data[i] - data[i-1];
- cout << "Diff " << i << ": "<<diff[i-1] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement