一道编程题,麻烦高手解答c++

来源:百度知道 编辑:UC知道 时间:2024/06/30 06:14:48
一些人轮流报数,报到7的倍数或含有7的数字时,要报的那个人就要说apple。有可能听到一个连续几次apple
输入:

每次一行输入一个n(1<=n<=99)代表连续听到"apple"的次数,输入以EOF结束。

输出:
能听到n次"apple"的最小的数。

Sample Input:
2
3

Sample Output:
27
70

最好在23:00前做好!
现在主要是卡在输出最小数和如果与n不符怎么断掉的问题上。
现在只能做到你给我一个n,我给你输出7。
因为程序只是单纯的从1运行到有n个apple的时候。
请高手指点!
……

你看看这个函数,我没编译,应该有错,大概就是这样

int test7(int i) {
char str[256];
if (i % 7 == 0) return 1;
itoa(i, str, 10);
for (int k = 0; str[k] != '\0'; k++) {
if (str[k] == '7') return 1;
}
return 0;
}

int find7(int n) {
int i = 1;
while (1) {
if (test7(i)) {
int count = 1;
while (1) {
if (count == n) return i;
i++;
if (test7(i)) {
count++;
} else break;
}
}
i++;
}
}

#include<stdio.h>
int f(int j)
{
while(j!=0)
{
if(j%10==7){return 1;break;}
else j=j/10;
}
return 0;
}
int main()
{
int p,n,i,j,temp;
int a[100],b[101];
scanf("%d",&p);
for(i=0;i<p;i++)
scanf("%d",&a[i]);