How to write a Java program that reads a phrase from the input and outputs its words in reverse order?
98590
import java.util.*;\npublic class HelloWorld {   \n   public static Stack stack=new Stack(); \npublic static void main(String[] args) {\n   try {\n   String s="this is java string reverse ";\n   reverseString(s);\n   System.out.println("the reversed string value is ");\n   for(int i=stack.size()-1;i>=0;i--){\n   System.out.print(stack.get(i));\n   }\n       } \n   catch (Exception e) {\n            e.printStackTrace();\n       }\n    }\n   public static void reverseString(String s) throws Exception{\n      StringTokenizer temp=new StringTokenizer(s);\n   if(temp.hasMoreTokens()){\n   String s1=temp.nextToken();\n   stack.push(s1+" ");  \n   reverseString(s.substring(s1.length()+1));\n   }\n   else{\n   return;\n   }     \n   }  \n   \n}
923748
Yes, there are several (So-called Reverse Dictionaries). My favorite is:\n\nhttp://www.onelook.com/reverse-dictionary.sh
129073
The code below will work.\n\nint main()\n{\nint aNum,i;\ncout<<"enter a number";\ncin>> aNum;\nfor(i=0;i<aNum;i++)\n{\nfor(j=0;j<=i;j++)//nested loop\ncout<<"*";// end of nested loop\ncout<<'&#92;n';\n}// end of outer loop\nreturn 0;\n}
260093
Here it is:-\n\n/* Convert.cpp */\n/* Display the reverse of the input */\n/* By Senthil */\n\n#include <iostream.h>\n#include <conio.h>\n#include <string.h>\n\nvoid main()\n{\nchar inp[10];\nint cnt = 0, ex = 0;\nclrscr();\n\ncout<<"Enter some characters (max limit 10) : ";\ncin>>inp;\n\ncnt = strlen(inp);\ncnt--;\nfor(ex = 0;ex != cnt;ex++,cnt--)\n{\ninp[ex] = inp[cnt];\n}\ncout<<"The reverse of the string is : "<<inp;\ngetch();\n}
172557
See if you can unscramble these words. You can read words with all the letters mixed up except for the first and last. Got an email like this not long ago.
526248
There are many answers to this:\n\n1) Take the string, make a reverse copy of it and compare the strings\n\n2) Pointer to the start index of the string and end index of the string and start comparing till you get strlen/2\n\n.... for more solutions and code you can search the web
2509
Here's a java solution that uses recursion.  The permute function takes two arguments: a done portion and a todo portion.   The basic idea is that each of the characters in the todo portion could be the next character.  So, at each step, n recursive calls are made, where n is the length of todo.  Each call chooses a different character as the next character to go into the done portion.  So, the first time the number of recursive calls will equal the number of characters in the initial string.  Each of these calls will make further recursive calls equal to the number of characters in the initial string minus one.  And so on.  Thus, the number of solutions will be n! = n*n-1*n-2*...*1, where n is the number of characters in the initial string.\n\nThe program below was tested with java's sun compiler 1.4.2.\npublic class perm\n{\n  public perm(String S)\n  {     \n    permute("", S);\n  }     \n  public void permute(String done, String todo) \n  {     \n    if ((todo.length()==0)||\n        (todo.equals("")))\n      System.out.println(done);\n    else        \n    {           \n      for (int i=0; i<todo.length(); i++)\n      {                 \n        String c = todo.substring(0,1);\n        todo = todo.substring(1);\n        permute(done+c, todo);  \n        todo = todo + c;        \n      }                 \n    }           \n  }     \n  public static void main(String args[])\n  {     \n    if ((args.length==0)||\n        (args[0].length()==0)||\n        (args[0].equals("")))\n      return;           \n    perm p = new perm(args[0]);\n  }     \n}
277112
try\n\nhttp://www.ciphersbyritter.com/LEARNING.HTM
1158354
This does not require hiring a professional, it's a rather simple & straightforward program. \n\nRaven put you on the right track, use the modulo (%) operator to break out the thousands from the hundreds, the hundreds from the tens, etc.  Define an array or map of strings with the words for each number up to twenty, then thirty, forty, fifty.. to ninety, then hundred, thousand.  Break the number apart, and get the appropriate words from the array & string them together.
207892
I'm not going to write any code for you, but I've got some ideas.\n\nIf you don't care whether the program uses real words, then implementation should be pretty easy.\n\nFirst, for each sentence, have the program decide how many words should be in the sentence. Then, for each word, have the program decide how many letters should be in the word. The program should alternate between consonants and vowels in order to ensure that the gibberish is still pronouncable. The program could also have a set probability for inserting parenthesis or commas, perhaps 1 in 7 for a comma and 1 in 40 for parenthesis. Be sure that the first word in the sentence begins with a capital letter. At the end of the sentence, the program should decide whether to end with a period, question mark, or exclamation point. You can then repeat for however many random sentences you would like.\n\nNow, if you want the program to use REAL words, you'll have to do a bit more work. First, you'll need a list of words, a "dictionary" so to speak. This will need to contain a lot of information if you want to make sentences using real words. You'll need information about its part of speech (noun, verb, adjective, adverb, interjection, etc.), gender (masculine, feminine, neuter), if the word is a verb whether it has any irregular forms or whether the verb is transitive or intransitive, if the word is a noun whether it has irregular plurals (e.g. "datum" and "data", or "goose" and "geese") or whether it's a proper noun none, some, or all of the time, if the word is an adjective whether it can be made into an adverb by adding -ly, and basically information for any other question that might come up when making a sentence. That's probably more than enough work right there. BUT, once that's taken care of, the program can use the random number generator along with the rules of grammer to make a sentence "framework", then simply select random words of the right part of speech to "fill in the blanks". For example:\n\n(?article?) (?adjective?) (noun) (?adverb?) (verb) (?article?) (?adjective?) (?noun?)\n\nThe question marks indicate optional parts of speech for such a framework sentence. The program might make sentences like the following:\n\nA blue apricot graciously impregnates the tall monkeys.\nThe car likes reality.\nBarns reluctently hold a safe hose.\nA baby vomits.\n\nIf you get really advanced, you can create other "sentence frameworks":\n\n(?article?) (?adjective?) (noun) was (?adverb?) (verb-past_participle) ?by? (?article?) (?adjective?) (?noun-posessive?) (?article?) (?adjective?) (?noun?)\n\nA velvet god was almost smashed by the delicious boss's happy dollars.\nMatthew was totally x-rayed by butter.\nA red vending machine was inflated by pride.\nThe rediculous baseballs were swallowed.\n\nIn conclusion, you'll have to apply all of your linguistic knowledge and problem solving skills -- not to mention a lot of time -- on this one. Actually it sounds like something I'd like to try. E-mail me if you're interested.
13285
In the form of Alphabet Soup?
577890
Yes, when there are words like that, they are called palindromes. Another example could be level.
665172
inversions - most don't usually read the same though.  One example of when this IS the case is "MOW".  However WOW reads MOM upside down but is still called an inversion.
277165
Try the following:\nchar str [255];\nchar s_wrd1[80];\nchar s_wrd2[80];\nchar s_wrd3[80];\n\nfscanf(tFile, "%s", str);\nsscanf(str, "%s %s %s", s_wrd1, s_wrd2, s_wrd3);\n\nThe first 3 words will be stored in s_wrd1, s_wrd2 and s_wrd3 variables.\n\nAbout the hard return, it doesn't matter whether you have it or not.
977594
The term you are looking for is "palindrome".
721341
try SpamAssassin.  i don't remember what language it's in, but it would be a snap to re-write it in Java.
137760
Object\n\n1) enclose it in braces\nString [] apple = {"a", "b", "c"};\n\n2) read it into what?  Array?  ArrayList?  I can do it in four lines...\nString line;\nBufferedReader br = new BufferedReader(new FileReader("build.xml"));\nwhile ((line = br.readLine()) != null) {/*do something here*/}\nbr.close();\n\n3) string.replace\nString banana = "This'is'a'test";\nSystem.out.println(banana.replace("'", ""));\n\n(In case that's hard to read - the method is "replace" openparin doublequote singlequote doublequote comma doublequote doublequote closeparin)