1
0

hw_practice.c~ 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. typedef int Info_t;
  5. typedef struct node {
  6. Info_t Info;
  7. struct node *next;
  8. } Node;
  9. typedef struct head {
  10. Node first;
  11. Node last;
  12. } Head;
  13. void permute (int i, int n, char str[]);
  14. int main ( int argc , char ** argv ){
  15. int n = 50;
  16. int * sequence = calloc(n, sizeof(int));
  17. sequence[0] = n / 1.3;
  18. printf("%d ", sequence[0]);
  19. int i = 1;
  20. while(sequence[i - 1] > 1){
  21. sequence[i] = sequence[i - 1] / 1.3;
  22. if(sequence[i] == 9 || sequence[i] == 10){
  23. sequence[i] = 11;
  24. }
  25. printf("%d ", sequence[i]);
  26. i++;
  27. }
  28. printf("%d ", sequence[i + 1]);
  29. return EXIT_SUCCESS;
  30. }
  31. void swap (char *x, char *y){
  32. char temp;
  33. temp = *x;
  34. *x = *y;
  35. *y = temp;
  36. }
  37. void permute (int i, int n, char str[]){
  38. int j;
  39. int k;
  40. if (i == n){
  41. printf("%s\n", str);
  42. } else {
  43. for (j = i; j <= n; j++){
  44. swap(&str[i], &str[j]);
  45. permute(i + 1, n, str);
  46. swap(&str[i], &str[j]);
  47. }
  48. }
  49. }