Register and join over 40,000 other developers!
Recent Topics
-
The Game You Are Waiting For?
WendellHarper - Dec 06 2020 01:21 PM
-
Quora and Reddit Backlinks
WendellHarper - Dec 06 2020 01:14 PM
-
Delete account
pindo - Jul 23 2020 01:33 AM
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

[C++] Help with array sorting and ASCII code scanning
Started by Tonchi, May 15 2012 03:21 PM
linked list array ascii
1 reply to this topic
#1
Posted 15 May 2012 - 03:21 PM
Hello guys. I need some help. I'm not such in C++ like in C# and I will never be because I'm not so interested in that language but I need to do this task. So I will appreciate your help very much.
This is the text of task:
User enters N integers, N <= 40. Numbers need to be sorted ascending.
Result must be provided by linked list. After sorting, it's necessary
to check if there is numbers which is in range of ASCII code of letters and if does program
needs to write out so as the letters. Also it's neccesary to split letters in uppercase and lowercase
letters in special (self) fields, after that arrays needs to be sorted descending using sorting by replacement and
bubble sort in that order. Algorithm must be realised by function.
I know that I'm a big noob in C++ so I will appreciate your help.
This is the text of task:
User enters N integers, N <= 40. Numbers need to be sorted ascending.
Result must be provided by linked list. After sorting, it's necessary
to check if there is numbers which is in range of ASCII code of letters and if does program
needs to write out so as the letters. Also it's neccesary to split letters in uppercase and lowercase
letters in special (self) fields, after that arrays needs to be sorted descending using sorting by replacement and
bubble sort in that order. Algorithm must be realised by function.
I know that I'm a big noob in C++ so I will appreciate your help.
Microsoft Student Partner, Microsoft Certified Professional
#2
Posted 15 May 2012 - 06:56 PM
Hey Tonchi, I assumed you as you are devoted to learning.
What are your the arguments you have not to learn C++?
About your problem, first of all, this is a homework for you, right? We are not here to do your homework for you but we'll help you to learn the things so that you can do your homework (as an experienced user, perhaps you can understand that) . Second, there is a 'Homework' section on the homepage (I guess you know that too being an experienced user), try to remember to post your homework on that section from next time. Last, try to learn the following things and solve your problem. Perhaps I'll show some segment of code for a particular step too so that you don't need to do googling for that.
Step 1: First you need to know how to write a 'Hello C++ World!' program in C. It is as following.
Step 2: You need to know how to take an integer input from user.
Step 3: Now you need to know how to create a linked list. I think you already know what 'linked list' is. However you can refresh your memory from here -- http://en.wikipedia....ki/Linked_list. You also need to know about 'Pointer' -- http://www.cplusplus...rial/pointers/.
Step 4: In this step, you need to know how to traverse the 'Linked List'. http://en.wikipedia....iki/Linked_list -- in this link you will see how to traverse a linked list (see section 'Singly linked lists'). Following is the code that you can use to traverse your linked list.
Remaining things: To print your integer value (if it falls in the characters ascii range) to characters as follows.
I think you can do the other logic parts like bubble sorting and reversing. However, we can help you on those parts too if you face problem. I think you will be able to create a linked list with taking integers input from user and be able to print it by traversing the linked list. If you are able to do that, your can post your problem here you face with remaining parts.
What are your the arguments you have not to learn C++?
About your problem, first of all, this is a homework for you, right? We are not here to do your homework for you but we'll help you to learn the things so that you can do your homework (as an experienced user, perhaps you can understand that) . Second, there is a 'Homework' section on the homepage (I guess you know that too being an experienced user), try to remember to post your homework on that section from next time. Last, try to learn the following things and solve your problem. Perhaps I'll show some segment of code for a particular step too so that you don't need to do googling for that.
Step 1: First you need to know how to write a 'Hello C++ World!' program in C. It is as following.
#include <iostream> int main() { std::cout << "Hello C++ World!"; // this line will print to the console return 0; }
Step 2: You need to know how to take an integer input from user.
#include <iostream> int main() { std::cout << "Please provide an integer input"; // this line will print to the console int userInput; std::cin >> userInput; // this line will take input from user return 0; }
Step 3: Now you need to know how to create a linked list. I think you already know what 'linked list' is. However you can refresh your memory from here -- http://en.wikipedia....ki/Linked_list. You also need to know about 'Pointer' -- http://www.cplusplus...rial/pointers/.
#include <iostream> typedef struct LinkedListNode { int value; struct LinkedListNode *next; }; void createASampleLinkedListOfThreeNodes() { //create first/root node LinkedListNode* root = new LinkedListNode(); std::cin >> root->value; // take input integer for first/root node // create second node LinkedListNode* second = new LinkedListNode(); std::cin >> second->value; // take input integer for second node // linked second node to first/root node. root->next = second; // create third node LinkedListNode* third = new LinkedListNode(); std::cin >> third->value; // take input integer for third node // linked third node to second node. second->next = third; // nake third to point to nothing (NULL). third->next = 0; } int main() { createASampleLinkedListOfThreeNodes(); return 0; }
Step 4: In this step, you need to know how to traverse the 'Linked List'. http://en.wikipedia....iki/Linked_list -- in this link you will see how to traverse a linked list (see section 'Singly linked lists'). Following is the code that you can use to traverse your linked list.
void traverseLinkedList() { LinkedListNode *node = root; while(node != 0) { int intValue = node->value; // here is your integer value node = node->next; } }
Remaining things: To print your integer value (if it falls in the characters ascii range) to characters as follows.
int iValue = root->value; if ((iValue >= 65 && iValue <= 90) || (iValue >= 97 && iValue <= 122)) std::cout << (char)iValue;
I think you can do the other logic parts like bubble sorting and reversing. However, we can help you on those parts too if you face problem. I think you will be able to create a linked list with taking integers input from user and be able to print it by traversing the linked list. If you are able to do that, your can post your problem here you face with remaining parts.
Also tagged with one or more of these keywords: linked list, array, ascii
Language Forums →
C# →
Counting the integers frequences in an array entered by the userStarted by AndreMarques, 27 Nov 2017 ![]() |
|
![]() |
||
Language Forums →
PHP →
How Come Variable Not Assigned And Php Knows Where To Look For Value ?Started by uniqueideaman, 06 May 2017 ![]() |
|
![]() |
||
Language Forums →
C and C++ →
help me . c++. ArraysStarted by girl2383, 06 Feb 2017 ![]() |
|
![]() |
||
Language Forums →
C and C++ →
Selecting an element on a 2D arrayStarted by LonelyGuySylar, 18 May 2016 ![]() |
|
![]() |
||
Language Forums →
Java →
Include a specific error, task, problem, or question in your titleStarted by rjb7, 15 Apr 2016 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download