Error returning items not repeated and in alphabetical order

Asked

Viewed 279 times

-3

The code is in the image.

Statement: "Valentina is a very dedicated woman and usually works late every day. To save time, she makes the shopping list of the market in an app and usually notes down every item at the same time she notices it missing at home.

The problem is that the application does not delete duplicate items and as Valentina is distracted, notes the same item more than once and the list ends up getting extensive. Your task as a programmer and friend of Valentina is to improve the notes application by developing a code that excludes duplicate items from the shopping list and orders them alphabetically.

Entree The first line of entry contains an integer N (N < 100) that indicates the amount of test cases that follows, or rather the amount of shopping lists that Valentina wants to organize. Each purchase list consists of a single line containing 1 to 1000 items or words composed only of lower case letters (1 to 20 letters), without accents and separated by a space.

Exit The output contains N lines, each representing one of Valentina’s shopping lists, without repeating items and in alphabetical order."

Código feito que está dando erro

The hint of the error is that it has to do with some vector that is less capable than it needs or I’m trying to access an invalid memory, but have no idea how to fix it.

Help me out, please!

1 answer

0

Good afternoon, my friend.
The error in your code is in the following line:
if(! strcmp(vi[i], vi[i + 1]) == 0)
It is generating an address overflow in memory when it arrives at the end of the vector.
Check the variables of the counters, such as L1 putting the debug program line-to-line.
I hope I’ve helped you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.