Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Wjtektab2.cpp: Określa punkt wejścia dla aplikacji konsoli.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int n;
- const int MAX = 100;
- float A[MAX];
- int nrmin, nrmax;
- cout << "Podaj liczbe elementow wektora <=" << MAX << ". " << endl;
- cin >> n;
- if ((n > 0) || (n < MAX))
- {
- for (int i = 0; i < n; i++)
- {
- cout << "Podaj " << i + 1 << " element wektora: " << endl;
- cin >> A[i];
- }
- nrmin = 0;
- for (int i = 1; i < n; i++)
- {
- if (A[i] < A[nrmin])
- nrmin = i;
- }
- cout << "Najmniejszy element wynosi: " << A[nrmin] << " i jest na miejscu " << nrmin+1 << endl;
- nrmax = 0;
- for (int i = 1; i < n; i++)
- {
- if (A[i] > A[nrmax])
- nrmax = i;
- }
- cout << "Najwiekszy element wynosi: " << A[nrmax] << " i jest na miejscu " << nrmax + 1 << endl;
- }
- else
- cout << "Nie da sie utworzyc wektora. " << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement