1

This is what I made (finds the maxim size of entered string). Now I have to write this program with linked list (to show,delete and show the modified list). I didn't really understand nodes and that stuff.

#include <iostream>

int main() {
    int n, msize = 0;
    std::cin >> n;

    std::string a[n];

    for(int i = 0; i < n; ++i) {
        std::cin >> a[i];
        if(a[i].length() > msize) msize = a[i].length();
    }
    for(int i = 0; i < n; ++i) {
        if(a[i].length() == msize) {
        }
    }
}
Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • I guess you saw something like `struct node { std::string data; node* next; };`? What part is it that you don't understand. Please elaborate. – Ted Lyngmo Oct 19 '21 at 16:00
  • Unrelated: `std::string a[n];` is a [VLA](https://stackoverflow.com/questions/1887097/why-arent-variable-length-arrays-part-of-the-c-standard) and it's not valid in standard C++. Use : `std::vector a(n);` instead. – Ted Lyngmo Oct 19 '21 at 16:01
  • 1
    @Antonio Margina The C++ Standard already provides two lists std::forward_list and std::list.:) You can use them. – Vlad from Moscow Oct 19 '21 at 16:06

0 Answers0