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

这篇博客介绍了一个C语言程序,该程序能够解析用英文单词表示的数字,并进行加法运算。程序首先定义了一个`parse_int`函数来将英文单词转换为整数,然后在`main`函数中读取用户输入的英文单词形式的数字进行相加并打印结果。虽然最终输出是阿拉伯数字,但可以通过调整代码以返回英文单词形式的结果。
摘要由CSDN通过智能技术生成

匿名用户

1级

2010-05-09 回答

最后输出是用的是阿拉伯数字,这个你再改改吧, 小问题了。。。。

#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':

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值