HDU 1058

本文深入探讨了英语作为全球通用语言的重要性和学习方法,通过编程示例展示了如何使用C语言生成英语数字及其序数形式,并提供了英语数字的前5842个值。此文章不仅适合英语学习者,也对编程爱好者具有一定的启示作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

英语很重要……


#include "stdio.h"

#define MIN(a, b) ((a)>(b)?(b):(a))
#define MIN_FOUR(a, b, c, d) MIN(MIN(a,b), MIN(c, d))

long humble[5842];

void cal(){
	int i;
	int pos1, pos2, pos3, pos4;
	long na, nb, nc, nd;
	humble[0] = 1;
	pos1 = pos2 = pos3 = pos4 = 0;
	for(i=1; i<=5842; i++){
		humble[i] = MIN_FOUR( na=humble[pos1]*2, nb=humble[pos2]*3, nc=humble[pos3]*5, nd=humble[pos4]*7 );
		if(humble[i]==na) pos1++;
		if(humble[i]==nb) pos2++;
		if(humble[i]==nc) pos3++;
		if(humble[i]==nd) pos4++;
	}

}

void main(){
	int n;
	cal();
	while(scanf("%d", &n), n){
		printf("The %d", n);
		if(n%100!=11&&n%10==1) printf("st");
		else if(n%100!=12&&n%10==2) printf("nd");
		else if(n%100!=13&&n%10==3) printf("rd");
		else printf("th");
		printf(" humble number is %d.\n", humble[n-1]);
	}
}


评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值