求输入数字的所有质因数,并将所有质因数进行排序,并以质因数+空格的形式输出

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
static int cou;
int result[] = {};
void Rank(int add[],int n) //将求得的质因数进行冒泡排序,从小到大
{
int i,j,num;
for(i=;i<n-;i++){
for(j=;j<=n-i-;j++){
if(add[j]>add[j+])
{
num = add[j];
add[j] = add[j+];
add[j+] = num;
}
}
}
}
void getResult(long num) //求质因数算法
{
cou = ;
for(int i = ;i <= num;i++)
{
if(num%i == ){
result[cou++] = i;
num = num/i;
i = ;
}
}
Rank(result,cou);
} int main()
{
long int num;
scanf("%d",&num);
getResult(num);
for(int i = ;i < cou;i++)
{
printf("%d ",result[i]);
}
printf("\r");
return ;
}

ACM-求质因数的更多相关文章

  1. 2.C# 输入一个整数,求质因数

    C# 输入一个整数,求质因数 List<int> results = new List<int>(); int number = Int32.Parse(Console.Rea ...

  2. CF1444A Division 求质因数的方法

    2020.12.20 求质因数的方法 CF1444A Division #include<bits/stdc++.h> #define ll long long #define fp(i, ...

  3. C# 输入一个整数,求质因数

    质数,质因数 应该都了解,在这里不过多解释,直接上代码: List<int> results = new List<int>(); int number = Int32.Par ...

  4. Number Sequence(hdu4390)

    Number Sequence Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...

  5. TYVJ P1020 寻找质因数

    做题记录:2016-08-08 描述 给出N个数字,试求质因数最大的数字. 输入格式 第一行,一个整数N,表示数字个数.接下来N行,每行一个整数A_i,表示给出的数字. 输出格式 一个整数,表示质因数 ...

  6. UVA 11610 Reverse Prime (数论+树状数组+二分,难题)

    参考链接http://blog.csdn.net/acm_cxlove/article/details/8264290http://blog.csdn.net/w00w12l/article/deta ...

  7. linux c 分解质因数

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> ...

  8. HDU 1405 第六周 J题

    Description Tomorrow is contest day, Are you all ready?  We have been training for 45 days, and all ...

  9. hdu 1695 GCD(欧拉函数+容斥)

    Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD( ...

  10. HDU 6069

    Counting Divisors Problem Description In mathematics, the function d(n) denotes the number of diviso ...

随机推荐

  1. [日常] win10开启和安装ubuntu子系统

    在控制面板的程序与功能里启用和关闭windows功能打开,适用于linux的windows子系统 在微软商店里搜索ubuntu,直接点击安装就可以了 安装完成后的windows与linux的磁盘映射见 ...

  2. jt格式文件读取,osg显示插件更新

    osgdb_jt 最近还是更新了一下 osgdb_jt 插件.解码jt格式核心库jt_toolkit,通过静态链接到Plugin jt产生osgdb_jt插件,使得osg可以可视化jt格式文件. 用法 ...

  3. 201871010113-刘兴瑞《面向对象程序设计(java)》第十四周学习总结

    项目 内容 这个作业属于哪个课程 <任课教师博客主页链接>https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地址>http ...

  4. 【转】【好文章】更愉快的写css

    我在写CSS的时候经常会碰到些麻烦事儿: 1)看上去蛮简单的排版却写了很久 2)代码写的越来越散,总是这里补一句,那里补一句,没有条理性 3)margin.padding.font-size等属性在不 ...

  5. acwing 2 零一背包问题

    地址 https://www.acwing.com/problem/content/description/2/ 题目描述有 N 件物品和一个容量是 V 的背包.每件物品只能使用一次. 第 i 件物品 ...

  6. Java 的synchronized关键字使用

    synchronized 关键字是实现锁的一种方式,是在jvm层面实现的非公平锁,以下是使用synchronized的四种方式 synchronized 特性: 1.非公平锁 2.可重入性 1.作用在 ...

  7. WPF 绑定属性 XAML 时间格式化

    原文:WPF 绑定属性 XAML 时间格式化 XAML 时间格式化{Binding Birthday,StringFormat='yyyy-MM-dd '} public class AssetCla ...

  8. Norm比较

    目录 Introduction BN LN IN GN SN Conclusion Introduction 输入图像shape记为[N, C, H, W] Batch Norm是在batch上,对N ...

  9. Python变量与内存管理

    Python变量与内存管理 –与C语言中的变量做对比,更好的理解Python的变量. 变量 变量在C语言中  全局变量:其存放在内存的静态变量区中.  局部变量:代码块中存放在内存的代码区当中,当被调 ...

  10. Linux 部署 rabbitMQ集群

    1. 部署Erlang 1.1 RabbitMQ依赖于Erlang,版本对应请查看 https://www.rabbitmq.com/which-erlang.html 1.2 下载安装Erlang ...