C++ min_element()' will never be NULL hatası

RSK06

Hectopat
Katılım
29 Aralık 2020
Mesajlar
2.365
Çözümler
4
Daha fazla  
Cinsiyet
Erkek
[CODE lang="cpp" title="C++"]#include <iostream>
#include <vector>
using namespace std;

int main() {
char selection{};
vector<double> list{ 1, 2, 3, 4, 5 };
int new_num{};
double average{};
double total {};
vector<int> min_element();

do {
cout << "Menu options: \n" << endl;
cout << "P - Print numbers\nA - Add a number\nM - Display mean of the numbers\nS - Display the smallest number\nL - Display the largest number\n" << endl;
cout << "Enter your choice: ";
cin >> selection;
if (selection == 'P' || selection == 'p') {
cout << "displaying all the elements in list: [ ";
for (int i = 0 ; i < 5; i++)
cout << list << " ";

cout << " ]" << endl;
}
else if(selection == 'A' || selection == 'a') {
cout << "Add integer: ";
cin >> new_num;
cout << "Adding new number to the list: [ ";
for (int i = 0 ; i < 5; i++)
cout << list << " ";
cout << new_num << " ]" << endl;
cout << "\n" << new_num << " added.\n" << endl;

}
else if (selection == 'M' || selection == 'm') {
cout << "\nCalculating average of the list... " << endl;
for (auto ttl: list) {
total += ttl;
}
average = total / list.size();
cout << "\nThe Average is: " << average << "\n" << endl;
}
else if (selection == 'S' || selection == 's') {
vector<int> min_element();
cout << "\nThe Smallest element in the list is: " << min_element << "\n" << endl;
}

} while (selection != 'q' && selection != 'Q');
cout << endl;

return 0;
}[/CODE]

Burada min_element()' will never me NULL [-waddress] hatası.
.
@M. Sc jelly bean yardımcı olabilir misiniz?
 
Son düzenleme:
Uyarı! Bu konu 5 yıl önce açıldı.
Muhtemelen daha fazla tartışma gerekli değildir ki bu durumda yeni bir konu başlatmayı öneririz. Eğer yine de cevabınızın gerekli olduğunu düşünüyorsanız buna rağmen cevap verebilirsiniz.

Technopat Haberler

Geri
Yukarı