|
use std::sort() algorithm:
std::vector<int> v;
v.push_back(4);
v.push_back(2);
v.push_back(7);
std::sort(v.begin(), v.end());
sort() works the same with std::list and any kind of container...
|
|
|
|
|
do you still need any help ?
|
|
|
|
|
Thanks for my re-players my problem is solved...
|
|
|
|
|
Member 2023561 wrote: do you still need any help ?
why did you say this to me ?
|
|
|
|
|
sorry, I thought if you still need any help in Data Structure.
|
|
|
|
|
Member 2023561 wrote: sorry, I thought if you still need any help in Data Structure
are you on crack ?
i'm still not the one who asked the question !
what makes you think I need explanation about such things ?
|
|
|
|
|
The following code implements a class Account, which has a balance, functions to add and withdraw money, and a function to query the current balance.
#include <iostream>
using namespace std;
class Account
{
public:
Account();
Account(double bal);
void deposit(double amount);
void withdraw(double amount);
double get_balance() const;
private:
double balance;
};
Account::Account()
{
}
Account::Account(double bal)
{
balance = bal;
}
void Account::deposit(double amount)
{
balance = balance + amount;
}
void Account::withdraw(double amount)
{
if (balance >= amount)
balance = balance - amount;
}
double Account::get_balance() const
{
return balance;
}
Now implement a new class Bank. This bank has two objects, checking and savings, of the type Account that is described above. Implement four member functions:
deposit(double amount, string account)
withdraw(double amount, string account)
transfer(double amount, string account)
print balances()
Here the account string is “S” or “C”. For the deposit or withdrawal, it indicates which account is affected. For a transfer, it indicates the account from which the money is taken; the money is automatically transferred to the other account.
Test your program using the following transactions.
1. Deposit $5000 to savings
2. Deposit $8000 to checking
3. Withdraw $3500 from checking
4. Transfer $750 from savings to checking
i am tryin this quesyions out but if i can get extra help it will be much appreciated...thank u guys and girls..
|
|
|
|
|
And what have you done so far?
We aren't going to do your homework: you should try yourself and ask whenever you're stuck on a detail or a general design issue.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
mooshi mooshi wrote: i am tryin this quesyions out...
And what has that produced?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi All
I am new student to MCA.I need some example of Array.How can i store a Char type values in store and print.Plz help me
|
|
|
|
|
'Array' as such doesn't exist in C++. There are some stl containers such as std::vector, std::list and the C-style array.
Please try to be more specific in your question.
--
Arman
|
|
|
|
|
ok i have char see[3]='*'; and i want to store these see values and print one by one..
Plz help me
|
|
|
|
|
int main(){
char see[3];
see[0] = 's';
see[1] = 'e';
see[2] = 'e';
// or you can do above 3 steps in loop also
for (int a=0; a<3; a++) {
cout<<"enter a character:";
cin>>see[i];
}
for(int i=0; i<3; i++) {
cout<<see[i];
}
return 0;
}
Try this and start with any of book suggested by sandip.
|
|
|
|
|
I recommend you get some good book for 'C'.
Your are MCA student so i think you are from India.
If yes,Please have a look at "Let us C" this is very good for beginners.
There are other good books also like "Schaum's Series" etc.
Regards,
Sandip.
|
|
|
|
|
|
If you are looking for a simple c++ program to store character strings in a character array and print them, then have a look at the follwowing piece of code :
void main()
{
char see[3][256] = {"\0" };
for (int nCntr = 0; nCntr < 3; nCntr++)
sprintf (see[nCntr], "%d", nCntr);
for (int nCntr = 0; nCntr < 3; nCntr++)
printf ("\n%s", see[nCntr]);
}
Is that what you wanted??
|
|
|
|
|
raesa wrote: If you are looking for a simple c++ program...then have a look at the follwowing piece of code :
What part of your code is C++?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I'm sorry, i mis-wrote it as 'c++', its actually 'c'.Thnx for pointing out the mistake.
|
|
|
|
|
For instance:
char myCharArray[]={ 'a', 'b', 'c', 'd', 'e'};
char c = myCharArray[3];
BTW Good C tutorial needed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
rdop wrote: I am new student to MCA.
Unless you have 0 experience with the C language, a person pursuing a Master's degree, especially in a computer-related field, should easily be able to find this with minimal effort.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi all,
I have made a dialog based application in that i have made a List control and a button....
On that button click event a timer has been called every 10000 ms and inside that timer i have called a worker thread which is calculating some values and then i want to diaplay those values in that list control, for that i have made a object of a class and then i am inserting the values... but as soon as control reaches there program crashes and give a debug assertion failed error...
i just wanted to known how to remove this??/
Thanks in advance
|
|
|
|
|
VCProgrammer wrote: but as soon as control reaches there program crashes and give a debug assertion failed error...
We can't start guessing unless you show us the code with causes the crash!
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
CTestDlg *obj = new CTestDlg;
int r = obj->m_List.GetItemCount();
obj->m_List.InsertItem(r,Header);
|
|
|
|
|
VCProgrammer wrote: CTestDlg *obj = new CTestDlg;
Have you created this dialog by calling it's Create function or DoModal?
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|