标签:c++ humble else bsp can pac include \n color
注意输出有点坑,只特判个位1 2 3输出格式是不对的,还要注意十位不能为1,比如112 111后边都是th而不是nd st,就这一点坑的地方
#include <bits/stdc++.h> using namespace std; #define LL long long LL a[6000]; int len; void dabiao() { len=0; LL i,j,k,l; for(i=1;i<=2000000000;i*=2) { // a[len++]=i; //printf("%lld****\n",a[len-1]); for(j=1;j*i<=2000000000;j*=3) { //a[len++]=j*i; for(k=1;j*i*k<=2000000000;k*=5) { //a[len++]=j*i*k; for(l=1;j*i*k*l<=2000000000;l*=7) a[len++]=i*j*k*l; //printf("************\n"); } } } sort(a,a+len); } int main() { int n,i,m; dabiao(); //sort() while(scanf("%d",&n),n) { printf("The %d",n); m=n/10%10;//十位不能为1,eg:11 12 13 111 112 113,,, if(n%10==1&&m!=1) printf("st "); else if(n%10==2&&m!=1) printf("nd "); else if(n%10==3&&m!=1) printf("rd "); else printf("th "); printf("humble number is %d.\n",a[n-1]); } }
标签:c++ humble else bsp can pac include \n color
原文地址:https://www.cnblogs.com/nr1999/p/9637175.html