How can I use bubble sort to go descending in C++ and how can I..?
399349
I can't really figure out what you are trying to do? How are the numbers going to be turned into months? How are you trying to output them? I don't know if you left this code out, but this would be helpful in answering. Please post more details.
505044
Try Planet Source Code:\n\nhttp://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=3270&lngWId=3\n\nThis one's in C++, but you should be able to convert it back to C...
2853
I always recommend Bjarne Stroustrup's "The C++ Programming Language", third edition.  It cuts straight to the meat of what is different between C and C++ instead of messing around with arrays of char like most tutorials do.
1174010
Buy a book. Online tutorials never helped me. I bought C++ for dummies. Its not bad.
697744
I'm not 100% sure I agree with that answer ({3,7,2...}), but regardless...\n\nQuicksort is a sorting algorithm (collect them all!) which breaks the problem of sorting a set of values into one of sorting two small sets of values, a strategy known as "divide and conquer".  It's also an "in place" sorting algorithm, meaning you can actually move values around in the set itself instead of having to work on copies.\n\nIn a quicksort, you pick a "partition" (I guess your teacher is calling it a "fence").  This can be any value in the set, and if your set is always nice & random like this you can just grab the first one instead of wasting time trying to find the median value or anything like that.\n\nOk, so in your example, your partition (fence) value is 10.  So, loop through the set and break it into two lists: everything less than 10, and everything greater than or equal to 10.  Now, you apply the same algorithm to the two lists.  Pick a pivot value in the "less than" list and split it into everything smaller than that value and everything greater than it.  Do the  same to the "greater than" list.  Keep narrowing down the sizes of these lists until you get to a list with a size of 1.  When you exit all the recursive calls, you'll find that the values in the set were sorted.\n\nIt's called a "quicksort" because it's incredibly fast compared to other sorting algorithms.  If written with threading in mind, the sorting tasks can even be split up among multiple CPUs if your system has more than one to make everything even faster.\n\nOh yeah, it's also ok to use a different sort algorithm after a while rather than recursively quicksorting these smaller & smaller lists.  So in that case you'd partition maybe once or twice...maybe three or four times...and then do a shell sort or something on the really small sets rather than break them down further.\n\nIt might help to watch a quicksort in action.  Check out the cool Java applet at this site (about halfway down):\n\nhttp://www.wanginator.de/studium/applets/quicksort_en.html\n\nYou'll have to put the values in one by one, but once you're done keep clicking "next step" to see how the partitioning and sorting works.\n\nOh yeah, I don't see why {3,7,2} should be the order of the "less than" set after just the first step.  Going left to right would give {2,3,7} and going right to left would give {7,3,2}.  What weird method of traversing a set gives that kind of order?
444754
This sounds like school work, its a fairly simple program. you will probably want to use the cout and cin function which needs you to include iostream.h \n\nsimply use cout to print to screen, ask for input etc. then take the input using cin and store it to a int variable.\n\na good way to do it would be to ask the user what they wish to do, eg subtract, divide and take that operator first, a symbol or a number to show choice. then the next line asks for the numbers to be input.\n\neg:\n\n---------\n\nHello. what do you wish to do:\n1 - subtract\n2 - divide\n3 - etc etc\n\n>\n\n-------------\n\nthen use an if function or maybe a switch to check what their input was and do the artithmatic.\n\nso a very basic prgram may look like this:\nit may have errors i havant checked it.\n\n-----------------\n\n#include <iostream>\n\nint main() \n{\nint number;\n\n    cout << "Hello, input a number" << endl;\n    cin >>number;\n    return 0;\n}\n\n------\n\nEDIT; i re read the req, you might find inputting the selection to a char better, then check the char to see what symbol is stored in it, eg + / -. and maybe use a char array for the number input. simple take the char array, check for the space. split the numbers into 2 and caste then to an int. sounds complicated but it isnt to hard.\n\nsorry about spelling mistakes.
813680
i'll give you the basic syntax..fill in the rest yourself\n\n#include<iostream.h>\n#include<conio.h>\n#include<stdio.h>\n\nvoid main()\n{\n  clrscr();\n   cout<<"&#92;t&#92;t Currency converter "<<endl;\n  cout<<"&#92;n 1) US dollars to peso "<<endl;\n  cout<<"&#92;n 2) US dollars to Euros "<<endl;\n  cout<<"&#92;n 3.........  "<<endl;\n  cout<<"&#92;n 4 ..... "<<endl;\n .....................................\n........................................\ncout<<"&#92;n enter your choice ";\ncin>>choice;\n\nswitch(choice)\n  {\n     case 1:\n       clrscr();\n        cout<<"&#92;n enter the amount in US dollars you want to convert to pesos ";\n      cin>>amount;\n      cout<<"&#92;n&#92;n "<<amount<<" dollars are equal to "<<amount*9.32 <<" pesos "<<endl;\n     break;\n     case 2 :\n        clrscr();\n        cout<<"&#92;n enter the amount in US dollars you want to convert to Euros ";\n....................................\n ...........................\n   case 3:\n ...................................\n...\n\ndefault :\n   cout<<"&#92;n invalid choice...";\n   exit(0);\n   }\n\ngetch();\n   \n\n}
102513
Sorts:\n\n http://www.programmersheaven.com/zone3/cat475/index.htm\n\nBinary search:\n\n http://physicsresearch.may.ie/yr3compphys/BorlandC2004.doc
971319
#include <iostream>\n#include <iomanip>\n\nusing namespace std;\n\nint main() {\n\n  cout << "Welcome to F&#92;'Zone&#92;n"\n      << "&#92;n"\n      << "Please select from the following menu.&#92;n"\n      << "&#92;n"\n      << "1: Quarter pounder combo&#92;n"\n      << "&#92;n"\n      << "2: Bacon burger&#92;n" \n      << "&#92;n"\n      << "3: Swiss mushroom burger&#92;n"\n      << "&#92;n"\n      << "To place your order, enter the number of the meal you would like.&#92;n"\n      << "For instance enter 2 for a Bacon Burger.&#92;n"\n      << "&#92;n"\n      << "Please enter your selection now: ";\n  char x;\n  x = getchar();\n  double total = 0.0;\n  switch (x) {\n    case '1' :\n      total = 4.59;\n      cout << "Would you like a &#92;'biggy&#92;' size? It costs $0.39 extra.&#92;n"\n          << "Type in a 'Y' or a 'N': ";\n      //x = getchar();\n      cin >> x;\n      if (x == 'Y') {\n        total += 0.39;\n        cout << "You have chosen to have a &#92;'biggy&#92;' size.&#92;n";\n      }\n      cout << "Would you like cheese with that? It costs $0.25 extra.&#92;n"\n          << "Type in a 'Y' or a 'N': ";\n      //x = getchar();\n      cin >> x;\n      if (x == 'Y') {\n        total += 0.25;\n        cout << "You have chosen to have cheese.&#92;n";\n      }\n      break;\n    case '2' :\n      // similar to 1, just change the price and messages.\n      break;\n    case '3' :\n      // similar to 1, just change the price and messages.\n      break;\n    default :\n      cout << "You have not ordered a menu item.";\n      return 1;\n  }\n  cout << "The total of your order is $" << setiosflags(ios::fixed)\n      << setprecision(2) << total << resetiosflags(ios::fixed);\n}
697721
First up you are going to need a compiler, you can get a free one here.\nhttp://www.borland.com/downloads/download_turbo.html\n\nInformation about it can be found here.\nhttp://www.turboexplorer.com/\n\nSome tutorials for c++ can be found here.\nhttp://www.cs.wustl.edu/~schmidt/C++/\n\nhttp://www.cplusplus.com/doc/tutorial/\n\nYou do not have to worry about memory allocation in C++, you can deal with it if you want, but you can avaoid it by using the keywords, 'new', 'delete', and 'delete[]'.\n\nRegarding the generation of random word segments, it would be done the same way as the random numbers are generated.\n\nIe, make an enum of these word segments,\nstring[] word_segments[5] = {"a", "an", "her", "ot", "etc"}\n\nWhen you get the random number, have it select a value from this array.\n\nword_segments[random_number];
646616
class publication\n{\n   private :\n      char title[20];\n      float price;\n   public :\n      void getdata()\n      {\n          cin>>title;\n          cin>>price;\n      }\n};\nclass books :: public publication\n{\n   private :\n      int pagecount;\n   public :\n      void getdata()\n      {\n          cin>>pagecount;\n      }\n\n};\nclass tape :: public publication\n{\n   private :\n      int playing_time;\n   public :\n      void getdata()\n      {\n          cin>>playing_time;\n      }\n};
305007
put ur curson on it, drag it to to the bottom
983655
click and drag it back to the bottom
869459
void main()\n{\nint n,rev=0,ro,n1;\ncout<<"enter the number";\ncin>>n;\nn1=n;\nwhile(n>0)\n{\nro=n%10;\nrev=rev*10+ro\nn=n/10;\n}\nif ( rev== n1)\n cout<<"the number is palindrom";\nelse\ncout<<"the number is not palindrom";\n}
138457
Assuming this is in C, this is an impossible problem given the main program you provided, because you're passing in the parameters by value rather than by reference.  So any changes you make to those values inside the function will disappear once you return to the main context.\n\nIf you're allowed to change the main program to use pointers, you could do this:\n\nvoid sort2 (int *a, int *b) {\n  int tmp;\n\n  if (*a > *b) {\n   tmp = *a;\n   *a = *b;\n   *b = tmp;\n  }\n}\n\nGiven your main program, you'd call it like this:\n  sort2(&u, &v);\n\nBut it may be that this assignment was given to you specifically to demonstrate that you can't change the value of variables that you pass in by value).
889418
1. Select the list or table you want to sort. \n2. On the Table menu, click Sort. \n3. Select the sort options you want.\n4. Click OK.
781094
Nobody is going to do your homework for you. \n\nIf you're supposed to write code examples that illustrate how two comparable programs might look, then do this. Write some simple programs in C, and then re-write the same program in C++ but put the functions your void main calls in a class and instantiate the class.