Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. В main.c
  2. #include <stdio.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5. #include "functions.h"
  6. В funcions.h
  7. #ifndef FUNCTIONS_H
  8. #define FUNCTIONS_H
  9.  
  10. bool checkUnique(int,char,bool);
  11.  
  12. bool IntNumber(char,int,int);
  13.  
  14. void replace(int*, int,int);
  15.  
  16. void printNum(int, int);
  17.  
  18. #endif
  19. В functions.c
  20. #include <stdio.h>
  21. #include <stdbool.h>
  22. #include <string.h>
  23.  
  24. bool checkUnique(int length,char a[10],bool verity){
  25. int k = 0;
  26. for(int i = 0;i<length-1;i++)
  27. if (a[i]==a[i+1])
  28. k++;
  29. if (k==length-1 && length !=1)
  30. verity = false;
  31. return verity;
  32. }
  33.  
  34. bool IntNumber(char enter[10],int number[10],int length){
  35. if (length > 10||length < 1)
  36. return false;
  37. for (int i = 0;i<length;i++){
  38. number[i] = enter[i]-'0';
  39. if (number[i] < 0||number[i] > 9)
  40. return false;
  41. }
  42. return true;
  43. }
  44.  
  45. void change(int*num, int firstIndex,int secondIndex){
  46. int t = num[firstIndex];
  47. num[firstIndex] = num[secondIndex];
  48. num[secondIndex] = t;
  49. }
  50.  
  51. void printNum(int num[10],int length){
  52. FILE*out;
  53. out = freopen("out.txt","a",stdout);
  54. for (int i = 0;i < length;i++)
  55. printf("%d",num[i]);
  56. printf("\n");
  57. fclose(out);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement