Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include"stdafx.h"
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int i, j, k, cul =0;
  9.  
  10. //辞書の定義
  11. char dictionary1sentence[20][10] = {
  12. "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine","ten",
  13. "eleven", "twelve", "thirteen", "fourteen", "fifteen","sixteen", "seventeen", "eighteen", "nineteen" };
  14. char dictionary2sentence[9][10] = {
  15. "", "twenty", "thirty", "forty", "fifty",
  16. "sixty", "seventy", "eighty", "ninety" };
  17. char dictionary3sentence[10] = { "hundred" };
  18. char dictionary4sentence[10] = { "thousand" };
  19.  
  20. // 1語のものを足す;1から19まで
  21. for (i = 1; i <= 19; i++){
  22. cul += strlen(dictionary1sentence[i]);
  23. }
  24.  
  25. // 2語のものを足す;20から99まで
  26. for (j = 1; j<9; j++){
  27. cul += strlen(dictionary2sentence[j]);
  28. for (i = 1; i <= 9; i++){
  29. cul += strlen(dictionary2sentence[j]) + strlen(dictionary1sentence[i]);
  30. }
  31. }
  32.  
  33. // 3語のものを足す(andを入れると4語だけど、、);100~999
  34. for (i = 1; i <= 9; i++){
  35. for (j = 0; j<9; j++){
  36. if (j == 0){
  37. cul += strlen(dictionary1sentence[i]) + strlen(dictionary3sentence);
  38. for (k = 1; k <= 19; k++){
  39. cul += strlen(dictionary1sentence[i]) + strlen(dictionary3sentence) + strlen("and") + strlen(dictionary2sentence[j]) + strlen(dictionary1sentence[k]);
  40. }
  41. }else{
  42. for (k = 0; k <= 9; k++){
  43. cul += strlen(dictionary1sentence[i]) + strlen(dictionary3sentence) + strlen("and") + strlen(dictionary2sentence[j]) + strlen(dictionary1sentence[k]);
  44. }
  45. }
  46. }
  47. }
  48.  
  49. //1000を含める
  50. cul += strlen(dictionary1sentence[1]) + strlen(dictionary4sentence);
  51.  
  52. cout << cul << endl;
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement