home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume36 / phone-nums / part01 next >
Encoding:
Text File  |  1993-04-18  |  6.1 KB  |  206 lines

  1. Newsgroups: comp.sources.misc
  2. From: friedenb@boswell.egr.msu.edu (Gedaliah Friedenberg)
  3. Subject: v36i111:  phone-nums - C++ Anagram for Phone numbers, Part01/01
  4. Message-ID: <1993Apr19.032148.13127@sparky.imd.sterling.com>
  5. X-Md4-Signature: 6e2f6c9c1af1ab9365a4e100713081a7
  6. Date: Mon, 19 Apr 1993 03:21:48 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: friedenb@boswell.egr.msu.edu (Gedaliah Friedenberg)
  10. Posting-number: Volume 36, Issue 111
  11. Archive-name: phone-nums/part01
  12. Environment: C++
  13.  
  14. I saw a post looking for an angaram that takes phone numbers and
  15. outputs all the possible word combinations from it.  I had a friend
  16. write this.  I am posting it for him and take no credit for it.
  17.  
  18. Ex. A University of Michigan fan might want a phone number 
  19. 646-2583 (M GO BLUE) or a Michigan State fan might have
  20. 772-7816 (SPARTAN).
  21.  
  22. This program will take your phone number and give you all of the possible
  23. word combinations.  A 7 digit phone number was assumed.
  24.  
  25. Since the numbers 1 and 0 have no letters associated with them, 
  26. the program will leave in the 1 or the 0 in the word cominations.
  27.  
  28. It was considered to put the program through a dictionary and only
  29. output the outcomes that are actual words.  But, since a person might 
  30. get a possible output of KSGKING (from a phone # of 574-5464) they 
  31. might want to know that they have the phone number of 574-KING (maybe
  32. they are an Elvis fan ;^)  My friend could not figure out a way to 
  33. look for possible words within the output unless the word was the entire
  34. 7 letters.
  35.  
  36. To use the program, just compile ('g++ phone-num.c -o phone-num') and type
  37. 'phone-num' to execute.  Enter each of the phone numbers on a line by itself.
  38. Ex.  355-2088 would be
  39. 3
  40. 5
  41. 5
  42. 2
  43. 0
  44. 8
  45. 8
  46.  
  47. 2,200 possibilities exist, so you might want to redirect the output to a
  48. file.
  49.  
  50. Gedaliah Friedenberg
  51. -=-Department of Mechanical Engineering
  52. -=-Department of Metallurgy, Mechanics and Materials Science
  53. -=-Michigan State University
  54. =======================
  55. #! /bin/sh
  56. # This is a shell archive.  Remove anything before this line, then feed it
  57. # into a shell via "sh file" or similar.  To overwrite existing files,
  58. # type "sh file -c".
  59. # Contents:  README phone-nums.c
  60. # Wrapped by kent@sparky on Sun Apr 18 22:03:25 1993
  61. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  62. echo If this archive is complete, you will see the following message:
  63. echo '          "shar: End of archive 1 (of 1)."'
  64. if test -f 'README' -a "${1}" != "-c" ; then 
  65.   echo shar: Will not clobber existing file \"'README'\"
  66. else
  67.   echo shar: Extracting \"'README'\" \(1449 characters\)
  68.   sed "s/^X//" >'README' <<'END_OF_FILE'
  69. XI saw a post looking for an angaram that takes phone numbers and
  70. Xoutputs all the possible word combinations from it.  I had a friend
  71. Xwrite this.  I am posting it for him and take no credit for it.
  72. X
  73. XEx. A University of Michigan fan might want a phone number 
  74. X646-2583 (M GO BLUE) or a Michigan State fan might have
  75. X772-7816 (SPARTAN).
  76. X
  77. XThis program will take your phone number and give you all of the possible
  78. Xword combinations.  A 7 digit phone number was assumed.
  79. X
  80. XSince the numbers 1 and 0 have no letters associated with them, 
  81. Xthe program will leave in the 1 or the 0 in the word cominations.
  82. X
  83. XIt was considered to put the program through a dictionary and only
  84. Xoutput the outcomes that are actual words.  But, since a person might 
  85. Xget a possible output of KSGKING (from a phone # of 574-5464) they 
  86. Xmight want to know that they have the phone number of 574-KING (maybe
  87. Xthey are an Elvis fan ;^)  My friend could not figure out a way to 
  88. Xlook for possible words within the output unless the word was the entire
  89. X7 letters.
  90. X
  91. XTo use the program, just compile ('g++ phone-num.c -o phone-num') and type
  92. X'phone-num' to execute.  Enter each of the phone numbers on a line by itself.
  93. XEx.  355-2088 would be
  94. X3
  95. X5
  96. X5
  97. X2
  98. X0
  99. X8
  100. X8
  101. X
  102. X2,200 possibilities exist, so you might want to redirect the output to a
  103. Xfile.
  104. X
  105. XGedaliah Friedenberg
  106. X-=-Department of Mechanical Engineering
  107. X-=-Department of Metallurgy, Mechanics and Materials Science
  108. X-=-Michigan State University
  109. END_OF_FILE
  110.   if test 1449 -ne `wc -c <'README'`; then
  111.     echo shar: \"'README'\" unpacked with wrong size!
  112.   fi
  113.   # end of 'README'
  114. fi
  115. if test -f 'phone-nums.c' -a "${1}" != "-c" ; then 
  116.   echo shar: Will not clobber existing file \"'phone-nums.c'\"
  117. else
  118.   echo shar: Extracting \"'phone-nums.c'\" \(1194 characters\)
  119.   sed "s/^X//" >'phone-nums.c' <<'END_OF_FILE'
  120. X#include <iostream.h>
  121. X#include <stdio.h>
  122. X
  123. Xvoid main( void )
  124. X
  125. X{
  126. X
  127. X//  PHONE LETTER to NUMBER possibility sorter.
  128. X
  129. X  char button[35] = {"000111ABCDEFGHIJKLMNOPRSTUVWXY"} ;
  130. X  char co[7];
  131. X  short number[10];
  132. X  int a=0;
  133. X
  134. X  cout << "\n\nPlease type telephone number X<enter>X<enter> [seven times total]\n"; 
  135. X
  136. X  for( int i=0;i<7;i++ )
  137. X  {
  138. X    cin >> number[i];  
  139. X  }
  140. X
  141. X  cout << "\n\nNow Working\n";
  142. X
  143. X  for( i=0;i<3;i++ )
  144. X  {
  145. X    co[0]=button[((number[0])*3+i)];
  146. X
  147. X    for( int j=0;j<3;j++ )
  148. X    { 
  149. X      co[1]=button[((number[1])*3+j)];
  150. X
  151. X      for( int k=0;k<3;k++ )
  152. X      {
  153. X    co[2]=button[((number[2])*3+k)];a++;
  154. X
  155. X    for( int l=0;l<3;l++ )
  156. X        {
  157. X      co[3]=button[((number[3])*3+l)];a++;
  158. X          
  159. X      for( int m=0;m<3;m++ )
  160. X      {
  161. X        co[4]=button[((number[4])*3+m)];a++;
  162. X           
  163. X        for( int n=0;n<3;n++ )
  164. X        {
  165. X          co[5]=button[((number[5])*3+n)];a++;
  166. X         
  167. X          for( int o=0;o<3;o++ )
  168. X          {
  169. X        co[6]=button[((number[6])*3+o)];a++;
  170. X
  171. X        for(int p=0; p<7; p++)   // output letter combo
  172. X          cout << co[p] ;        
  173. X          cout << '\n';          // issue newline
  174. X        
  175. X          }  // ...
  176. X        } // ...
  177. X      } // ...
  178. X    }  // ....
  179. X      }   // ....
  180. X    }   // second letter
  181. X  }  // first letter
  182. X} // main
  183. END_OF_FILE
  184.   if test 1194 -ne `wc -c <'phone-nums.c'`; then
  185.     echo shar: \"'phone-nums.c'\" unpacked with wrong size!
  186.   fi
  187.   # end of 'phone-nums.c'
  188. fi
  189. echo shar: End of archive 1 \(of 1\).
  190. cp /dev/null ark1isdone
  191. MISSING=""
  192. for I in 1 ; do
  193.     if test ! -f ark${I}isdone ; then
  194.     MISSING="${MISSING} ${I}"
  195.     fi
  196. done
  197. if test "${MISSING}" = "" ; then
  198.     echo You have the archive.
  199.     rm -f ark[1-9]isdone
  200. else
  201.     echo You still must unpack the following archives:
  202.     echo "        " ${MISSING}
  203. fi
  204. exit 0
  205. exit 0 # Just in case...
  206.