Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- В main.c
- #include <stdio.h>
- #include <stdbool.h>
- #include <string.h>
- #include "functions.h"
- В funcions.h
- #ifndef FUNCTIONS_H
- #define FUNCTIONS_H
- bool checkUnique(int,char,bool);
- bool IntNumber(char,int,int);
- void replace(int*, int,int);
- void printNum(int, int);
- #endif
- В functions.c
- #include <stdio.h>
- #include <stdbool.h>
- #include <string.h>
- bool checkUnique(int length,char a[10],bool verity){
- int k = 0;
- for(int i = 0;i<length-1;i++)
- if (a[i]==a[i+1])
- k++;
- if (k==length-1 && length !=1)
- verity = false;
- return verity;
- }
- bool IntNumber(char enter[10],int number[10],int length){
- if (length > 10||length < 1)
- return false;
- for (int i = 0;i<length;i++){
- number[i] = enter[i]-'0';
- if (number[i] < 0||number[i] > 9)
- return false;
- }
- return true;
- }
- void change(int*num, int firstIndex,int secondIndex){
- int t = num[firstIndex];
- num[firstIndex] = num[secondIndex];
- num[secondIndex] = t;
- }
- void printNum(int num[10],int length){
- FILE*out;
- out = freopen("out.txt","a",stdout);
- for (int i = 0;i < length;i++)
- printf("%d",num[i]);
- printf("\n");
- fclose(out);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement