Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"stdafx.h"
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int i, j, k, cul =0;
- //辞書の定義
- char dictionary1sentence[20][10] = {
- "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine","ten",
- "eleven", "twelve", "thirteen", "fourteen", "fifteen","sixteen", "seventeen", "eighteen", "nineteen" };
- char dictionary2sentence[9][10] = {
- "", "twenty", "thirty", "forty", "fifty",
- "sixty", "seventy", "eighty", "ninety" };
- char dictionary3sentence[10] = { "hundred" };
- char dictionary4sentence[10] = { "thousand" };
- // 1語のものを足す;1から19まで
- for (i = 1; i <= 19; i++){
- cul += strlen(dictionary1sentence[i]);
- }
- // 2語のものを足す;20から99まで
- for (j = 1; j<9; j++){
- cul += strlen(dictionary2sentence[j]);
- for (i = 1; i <= 9; i++){
- cul += strlen(dictionary2sentence[j]) + strlen(dictionary1sentence[i]);
- }
- }
- // 3語のものを足す(andを入れると4語だけど、、);100~999
- for (i = 1; i <= 9; i++){
- for (j = 0; j<9; j++){
- if (j == 0){
- cul += strlen(dictionary1sentence[i]) + strlen(dictionary3sentence);
- for (k = 1; k <= 19; k++){
- cul += strlen(dictionary1sentence[i]) + strlen(dictionary3sentence) + strlen("and") + strlen(dictionary2sentence[j]) + strlen(dictionary1sentence[k]);
- }
- }else{
- for (k = 0; k <= 9; k++){
- cul += strlen(dictionary1sentence[i]) + strlen(dictionary3sentence) + strlen("and") + strlen(dictionary2sentence[j]) + strlen(dictionary1sentence[k]);
- }
- }
- }
- }
- //1000を含める
- cul += strlen(dictionary1sentence[1]) + strlen(dictionary4sentence);
- cout << cul << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement