SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main(){
  5.  
  6.     int n;
  7.     scanf("%d", &n);
  8.  
  9.     int a[100000];
  10.     int dem = 0;
  11.    
  12.     for (int i=1;i<=sqrt(n);i++){
  13.         if (n % i == 0){
  14.             a[dem] = i;
  15.             dem++;
  16.         }
  17.         if (i*i != n){
  18.             a[dem] = n/i;
  19.             dem++;
  20.         }
  21.     }
  22.  
  23.     // sap xep
  24.     for(int i=0;i<dem-1;i++){
  25.         for(int j=i+1;j<dem;j++){
  26.             if (a[i] > a[j]){
  27.                 int tmp = a[i];
  28.                 a[i] = a[j];
  29.                 a[j] = tmp;
  30.             }
  31.         }
  32.     }
  33.  
  34.     for(int i=0;i<dem;i++) printf("%d ",a[i]);
  35.  
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top