日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

用英文单词模拟数字计算c语言,C语言程序设计用英文单词模拟数学计算

發(fā)布時(shí)間:2023/11/30 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用英文单词模拟数字计算c语言,C语言程序设计用英文单词模拟数学计算 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

匿名用戶

1級(jí)

2010-05-09 回答

最后輸出是用的是阿拉伯?dāng)?shù)字,這個(gè)你再改改吧, 小問題了。。。。

#include

#include

#include

#include

#include

int carry = 0;

int parse_int(const char *s, int len)

{

char tens[10], units[10];

memset(tens, 0, sizeof(tens));

memset(units, 0, sizeof(units));

int i=0, count=0;

while (isalpha(s[i]))

tens[count++] = s[i++];

while (isspace(s[i]))

i++;

count = 0;

if (i == len) {

switch (s[count++]) {

case 'z':

return 0;

case 'o':

return 1;

case 't':

switch (s[count]) {

case 'w':

return 2;

case 'h':

return 3;

case 'e':

return 10;

}

case 'f':

switch (s[count]) {

case 'o':

return 4;

case 'i':

return 5;

}

case 's':

switch (s[count]) {

case 'i':

return 6;

case 'e':

return 7;

}

case 'e':

return 8;

case 'n':

return 9;

}

count = 0;

}

else {

while (isalpha(s[i]))

units[count++] = s[i++];

count = 0;

if (!strcmp(units, "zero"))

i = 0;

else if (!strcmp(units, "one"))

i = 1;

else if (!strcmp(units, "two"))

i = 2;

else if (!strcmp(units, "three"))

i = 3;

else if (!strcmp(units, "four"))

i = 4;

else if (!strcmp(units, "five"))

i = 5;

else if (!strcmp(units, "six"))

i = 6;

else if (!strcmp(units, "seven"))

i = 7;

else if (!strcmp(units, "eight"))

i = 8;

else if (!strcmp(units, "nine"))

i = 9;

switch (tens[count++]) {

case 'z':

return i;

case 'o':

return 10+i;

case 't':

switch (s[count]) {

case 'w':

return 20 + i;

case 'h':

return 30 + i;

}

case 'f':

switch (s[count]) {

case 'o':

return 40 + i;

case 'i':

return 50 + i;

}

case 's':

switch (s[count]) {

case 'i':

return 60 + i;

case 'e':

return 70 + i;

}

case 'e':

return 80 + i;

case 'n':

return 90 + i;

}

}

}

int main()

{

char A[20], B[20], line[100];

int i, count, a, b;

while (1) {

i = count = a = b = 0;

memset(A, 0, sizeof(A));

memset(B, 0, sizeof(B));

if (fgets(line, sizeof(line), stdin) == NULL)

break;

while (!isalpha(line[i]))

i++;

while (line[i] != '+')

A[count++] = line[i++];

count = 0;

i++;

while (!isalpha(line[i]))

i++;

while (line[i] != '=')

B[count++] = line[i++];

a = parse_int(A, strlen(A));

b = parse_int(B, strlen(B));

printf("%d\n", a+b);

}

return 0;

}

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的用英文单词模拟数字计算c语言,C语言程序设计用英文单词模拟数学计算的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。