你要求的返回值怎么可能呢即是整型的-1,又是string类型的字符串呢?我将增加的值给你求出来,你可以自己转换成需要的#include <iostream>
char* prodata (int data)
{
if(data %495 == 0)
{
return nullptr;
}
// char* ret = new(char[10]);
int data_add = 0; //在data后增加的值
int d = data*10;
int count = 0,count_flag;
while(1)
{
if((count == 2 && count_flag == 0)|| (count %10 == 0 && count_flag == 1) ||(count %100 == 0 && count_flag == 2))
{
count_flag++;
d*= 10;
}
data_add += 5;
if((d+data_add) %495 == 0)
{
break;
}
count ++;
}
std::cout<<data_add<<std::endl;
return nullptr;
}
int main(int argc, char const *argv[])
{
prodata(523);
return 0;
}
输出:
215 |