Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #define SIZE 100
- int Masiv[SIZE];
- int prom = 0;
- int input = 0;
- int value = 0;
- void check() {
- int checker;
- int Checking[SIZE];
- printf("The amount of numbers is:%d\n", prom);
- for (checker = 0; checker < prom; checker++) {
- printf("\nNumber you are looking for: ");
- scanf("%d", &Checking[checker]);
- printf("\n");
- for (value = 0; value < prom; value++) {
- if (Checking[checker] == Masiv[value]) {
- printf("The number matches\n");
- }
- else { printf("There are no matching numbers\n "); }
- }
- }
- }
- void MenuPrint() {
- printf("(1.)fill array:\n");
- printf("(2.)Proverka na elemnt po stoinost:\n");
- printf("(3.)Otpechatvane na masiv:\n");
- printf("(4.)Elemen s nai malka suma ot systavqshtite go cifri:\n");
- printf("(5.)Populvane na masiv:\n");
- printf("(6.)Populvane na masiv:\n");
- printf("(7.)Exit:\n");
- }
- void Array() {
- printf("Type down the count of numbers: ");
- scanf("%d", &prom);
- printf("\n");
- if (prom > 0 && prom < 32767) {
- }
- else {
- input = 7;
- printf("You can only type numbers!\n");
- }
- for (value = 0; value<prom; value++) {
- printf("Number [%i]: ", value + 1);
- scanf("%d", &Masiv[value]);
- if (Masiv[value] > 0 && Masiv[value] < 32767) {
- }
- else{ input = 7; }
- }
- }
- void printArray() {
- int value;
- for (value = 0; value<prom; value++) {
- printf("\n The numbers you chose:%d\n", Masiv[value]);
- }
- }
- void SumOfDigits() {
- int number, a, b, suma = 0;
- int min = 0;
- int i = 0;
- number = Masiv[0];
- while (number != 0) {
- b = number % 10;
- min = min + b;
- number = number / 10;
- }
- for (i = 1; i < prom; i++)
- {
- number = Masiv[i];
- a = number;
- suma = 0;
- while (a != 0) {
- b = a % 10;
- suma = suma + b;
- a = a / 10;
- }
- if (min > suma)
- {
- min = suma;
- }
- }
- printf("\nMinimum is: %i\n", min);
- }
- void menu() {
- FILE * fp;
- fp = fopen("file.txt", "w");
- fprintf(fp, "%s %s %s %d", "I", "Am", "lubo", 2017);
- fclose(fp);
- }
- int main() {
- int promenliva;
- for (promenliva = 0; promenliva<SIZE; promenliva++) {
- Masiv[promenliva] = 0;
- }
- MenuPrint();
- do
- {
- printf("\nSelect:");
- scanf("%d", &input);
- if (input > 0 && input < 7) {
- switch (input) {
- case 1:
- Array();
- break;
- case 2:
- check();
- break;
- case 3:
- printArray();
- break;
- case 4:
- SumOfDigits();
- break;
- case 5:
- break;
- case 6:
- break;
- case 7:
- break;
- }
- }
- else {
- input = 7;
- printf("You cannot type diffrent than 1 to 7\n");
- }
- } while (input != 7);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement