1
0

hw_practice.c 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. return EXIT_SUCCESS;
  29. }
  30. void swap (char *x, char *y){
  31. char temp;
  32. temp = *x;
  33. *x = *y;
  34. *y = temp;
  35. }
  36. void permute (int i, int n, char str[]){
  37. int j;
  38. int k;
  39. if (i == n){
  40. printf("%s\n", str);
  41. } else {
  42. for (j = i; j <= n; j++){
  43. swap(&str[i], &str[j]);
  44. permute(i + 1, n, str);
  45. swap(&str[i], &str[j]);
  46. }
  47. }
  48. }