![]() |
|
#1
|
|||
|
|||
array problemHi all, im new in C world and I need your's help for one simple prog.
Program: enter array like this A=(1,2,3,4,5,6) (number of elements n=6) you need to delete one element (z=4) from that A array and print A array like A=(1,2,3,5). ((sorry for bad english)) |
|
#2
|
||||
|
||||
|
Welcome to GID vaha....
So what's the problem you're having? Understanding the problem? Designing the solution? Coding the solution? Compiler arrors? Runtime errors? Logic errors? Read the Guidelines for posting requests for help so you understand what we need to help you solve your task. __________________
Age is unimportant -- except in cheese |
|
#3
|
||||
|
||||
|
Hello vaha,
As a new programmer you may have this sort of problems.Even i'm new to programming even i'm having this sort of problems. OK the problem you've got is very simple actually.Insert the following in your program to get u the result. CPP / C++ / C Code:
this is very simple is it not.Now you try yourself to insert an element at the desired position. Somewhat similar to this, but different. |
|
#4
|
|||
|
|||
|
i had problem when user enters all same numbers for array elemenets and want one to remove, and when element that user wants out of array is last one. no new array is alowed to use.
here is my raw code sample: CPP / C++ / C Code:
and one more qest. , how can i prevent users to enter letters for elements? when i enter program crash, is ther any way to do that with standard lib -stdio.h-? Last edited by vaha : 15-May-2005 at 08:02.
Reason: forgoth something to enter
|
|
#5
|
||||
|
||||
|
Your problems seems to be here:
CPP / C++ / C Code:
1 4 5 8 9 and z is 5 you end up with 1 4 8 8 9 in the array. What you need to do to remove z is Code:
Quote:
Not easily. This takes a completely different form of input than you probably can do at the moment. After a few more weeks of class this will be easier. Also read this tutorial on how to format your code. Your formatting make the code difficult to read because it is inconsistant. __________________
Age is unimportant -- except in cheese |
|
#6
|
|||
|
|||
|
Thanks WaltP,
Quote:
no, that loop do this: if i have 1.4.5.8.9 and z= 4 i get 1.5.8.9 But when i set z=9 result= 1.4.5.8.0 and if i have 2.4.4.6.7 i can't use this loop for z=4. Quote:
CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
|
the only problems are in your for loop conditions (I don't know if that will work, by "problem" i mean "different than the psuedocode")
"from 0 to n-1" is i < n. Therefore, the loop will run until i=n-1, and that will be its last run. Same for "from 0 to n-2" is i < (n-1). |
|
#8
|
|||
|
|||
|
problem is solved
CPP / C++ / C Code:
thaks all for help. |
|
#9
|
||||
|
||||
|
Quote:
CPP / C++ / C Code:
__________________
Age is unimportant -- except in cheese |
|
#10
|
|||
|
|||
|
Quote:
To prevent entering letters and sings. I have something like this: CPP / C++ / C Code:
|
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem modifying an array of char in a function | ronin | C Programming Language | 10 | 28-Mar-2005 18:15 |
| template comiling problems - need expert debugger! | crq | C++ Forum | 1 | 01-Feb-2005 21:26 |
| problem reading to a dynamic array | noamfrie | C Programming Language | 9 | 02-Jan-2005 18:35 |
| How to search an array problem | jenmaz | C Programming Language | 4 | 17-Nov-2004 01:58 |
| Problem in array | Kay Chan | C Programming Language | 2 | 05-Oct-2004 21:16 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The