谁能帮我解一下这道程序题,请用c++语言.Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number.The sequence 1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...shows the first 20 humble numbers.W

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/15 09:37:47

谁能帮我解一下这道程序题,请用c++语言.Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number.The sequence 1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...shows the first 20 humble numbers.W
谁能帮我解一下这道程序题,请用c++语言.
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number.The sequence 1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...shows the first 20 humble numbers.Write a program to find and print the nth element in this sequence Input The input consists of one or more test cases.Each test case consists of one integer n with 1

谁能帮我解一下这道程序题,请用c++语言.Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number.The sequence 1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...shows the first 20 humble numbers.W
#include <iostream>
using namespace std;

const int SIZE = 5842;

int main() {
int humbernumber[SIZE];
int ptr[4][2] = { { 2, 0 }, { 3, 0 }, { 5, 0 }, { 7, 0 } };
int index = 1, nextnumber, candidate;
int n;
humbernumber[0] = 1;
while (index < SIZE) {
nextnumber = -1;
for (int i = 0; i < 4; i++) {
while (humbernumber[ptr[i][1]] * ptr[i][0] <= humbernumber[index - 1]) {
ptr[i][1]++;
}
candidate = humbernumber[ptr[i][1]] * ptr[i][0];
if (nextnumber == -1 || nextnumber > candidate) {
nextnumber = candidate;
}
}
humbernumber[index] = nextnumber;
index++;
}
while (cin >> n && n > 0) {
cout << "The " << n;
if (n % 100 >= 11 && n % 100 <= 13) {
cout << "th";
}
else if (n % 10 == 1) {
cout << "st";
}
else if (n % 10 == 2) {
cout << "nd";
}
else if (n % 10 == 3) {
cout << "rd";
}
else {
cout << "th";
}
cout << " humble number is " << humbernumber[n - 1] << "." << endl;
}
}

谁能帮我解决一下这道C语言题 谁能帮我解决一下这道C语言题 谁能帮我解一下这道程序题,请用c++语言.Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number.The sequence 1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...shows the first 20 humble numbers.W 谁给我讲一下这道C语言题 输入2个数 列出中间的所有数然后找出他们的奇数和偶数 用C语言RT请帮我写一段C语言的程序 C语言:关于用辗转相除法递归求最大公约数,下面的程序有错误,请帮我改一下,int gcd(int m,int n){int r,t;if(m 谁能帮我分析一下这道c语言题目啊?~若运行以下程序时,从键盘输入 ADescriptor(表示回车),则下面程序的运行结果是#include main(){char c;int v0=1,v1=0,v2=0;do{switch(c=getchar()){case ′a′:case ′ C语言程序实验设计我对C语言是一窍不通,但要做实验,希望大家帮我做一下这几个实验,主要写一下程序和帮我讲解一下这个程序是怎样的:(1)设某城市的CO2排放量年增长率为0.5%,计算20年后 请帮我做这3道C语言选择填空题?12.4有以下程序:#includevoid fun(int *s){ static int j=0;do s[j]+=s[j+1];while(++j c语言,请解释一下我画波浪线的地方.这个程序几乎全看不懂. 请大侠帮我解决C语言 下列程序在运行时输入12.8,写出结果. 怎么用c语言编一个程序解二元一次方程 北大ACM中第1001浮点数这题咋做啊?请高人用C语言帮我实现一下, c语言这道题为什么是这个答案……请解释一下程序什么意思…l 请用C语言编写程序:1.输入10个整数,求出这10个数的平均数. ..帮我设计一下这个程序S=2^2/(1*3)*4^2/(3*5)*...*(2n)^2/((2n-1)*(2n+1)) 用C语言.. 怎么做C语言程序改错题 用c语言 二次方程根的程序.