Question
I have one array titled num. I am pretending that the values stored in num represent frequency of letters being used.I currently have the value
I have one array titled "num". I am pretending that the values stored in "num" represent frequency of letters being used.I currently have the value being pointed and fixed to an addresses even after being placed in ascending order.I would like to always associate the first value in array "num" with the letter a and the second value with the letter b third number with letter c and so on till the letter z even after changing the array "num" into an ascending order.I wanted to have them someone how ASCII value of the letters so i properly display the letter with the integer value.
example array int num[] = {10,34,654,23}; 10:letter a 34: letter b 654: letter c 23: letter d
after being placed in asceding order 10: letter a 34: letter b 23: letter d 654: letter c
** **Can someone please demonstrate a c++ code that will fix all my orginal intergers the addresses of the letter to alaphabet.*****
below show my current code
// CODE #include
int main() { int num[] = {10,34,654,23}; // original array int len = sizeof(num)/sizeof(num[0]); // find its length int *num2[len]; // create a new array of pointers int *ptr; // instead of storing the values in num2, store their addresses for(int i = 0; i *num2[j]) { // swap the addresses not the values int *temp = num2[i]; num2[i] = num2[j]; num2[j] = temp; } } } // print the values after sorting cout
files trailtowards.cpp - [Executing] - Dev-C++5.11 t Execute Tools AStyle Window Help TDM-GCC 4.9.2 64-bit CAUserslaidanl Desktoplcoding files trailtowards.exe ltowards.cpp [1 vector.cpp assignment3almost.cpp swap78.cpp Printing the values of num21] before sort 10 at 0x6ffde0 34 at 0x6ffde4 654 at 0x6ffde8 23 at 0x6ffdec Swapping the values rinting the values of num2[] after sort 10 at 0x6ffde0 23 at 0x6ffdec 4 at 0x6ffde4 654 at 0x6ffde8 // CODE include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started