fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void) {
  5. int n,a[2][25],i,j;
  6. printf("Enter the no. of items\n");
  7. scanf("%d",&n);
  8. printf("Enter the items\n");
  9. for(j=0; j<n; j++)
  10. {
  11. scanf("%d",&a[0][j]);
  12. }
  13. for(j=0; j<n; j++)
  14. {
  15. printf("i: %d\n", i);
  16. a[1][j] = facts(a[i][j]);
  17. }
  18.  
  19. for(int x=0; x<n; x++)
  20. {
  21. for(int y=0; y<n-1; y++)
  22. {
  23. if(a[1][y]>a[1][y+1])
  24. {
  25. int temp = a[1][y+1];
  26. int temp1 = a[0][y+1];
  27. a[1][y+1] = a[1][y];
  28. a[0][y+1] = a[0][y];
  29. a[1][y] = temp;
  30. a[0][y] = temp1;
  31. }
  32. }
  33. }
  34.  
  35. for(j=0; j<n; j++)
  36. {
  37. printf("%d\t", a[0][j]);
  38. }
  39.  
  40. return 0;
  41. }
  42.  
  43. int facts(int h)
  44. {
  45. int factors=0;
  46. for(int k=1; k<=h; k++)
  47. {
  48. if((h%k)==0)
  49. {
  50. factors++;
  51. }
  52. }
  53. return factors;
  54. }
Success #stdin #stdout 0s 2164KB
stdin
1
3
stdout
Enter the no. of items
Enter the items
i: 0
3