大整数的因子c语言,大整数的因子

#include

#include

#include

#include

using namespace std;

int main() {

string str;

getline(cin, str);

char ch[30];

strcpy(ch, str.c_str());

int num = str.length();

int out[8];

int outCount = 0;

if (ch[num-1] == '0' || ch[num-1] == '2' || ch[num-1] == '4' || ch[num-1] == '6' || ch[num-1] == '8') {

out[outCount++] = 2;

int temp = 0;

for (int i = 0; i

temp += ch[i] - '0';

if (temp % 3 == 0)

out[outCount++] = 6;

temp = 0;

temp = (ch[num-2] - '0') * 10 + ch[num-1] - '0';

if (temp % 4 == 0)

out[outCount++] = 4;

temp = (ch[num-3] - '0') * 100+(ch[num-2] - '0') * 10 + ch[num-1] - '0';

if (temp % 8 == 0)

out[outCount++] = 8;

}

int total = 0;

for (int i = 0; i

total += ch[i] - '0';

}

if (total % 3 == 0)

out[outCount++] = 3;

if (total % 9 == 0)

out[outCount++] = 9;

if (ch[num-1] == '0' || ch[num-1] == '5')

out[outCount++] = 5;

total = 0;

if (num <= 3) {

if (num == 1) {

if (ch[0] == '7')

out[outCount++] = 7;

}

if (num == 2) {

if (((ch[0] - '0')*10 + (ch[1] - '0')) % 7 == 0)

out[outCount++] = 7;

}

if (num == 3) {

if (((ch[0] - '0')*100 + (ch[1] - '0') * 10 + (ch[2] - '0')) % 7 == 0)

out[outCount++] = 7;

}

}

else {

for (int i = num - 4; i>=0; i--) {

if (i == num - 4)

total = (ch[i] - '0') * 100 + (ch[i + 1] - '0') * 10 + (ch[i + 2] - '0') - (ch[i + 3] - '0') * 2;

else {

total += (ch[i] - '0') * 1000;

int temp1 = total % 10;

total /= 10;

total = total - temp1 * 2;

}

}

if (total % 7 == 0)

out[outCount++] = 7;

}

sort(out, out + outCount);

if (outCount>0) {

for (int i = 0; i

if (i == outCount - 1)

cout << out[i];

else

cout << out[i] << " ";

}

cout << endl;

}

else

cout << "none" << endl;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值