Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.65 KB | None | 0 0
  1. #include "stdio.h"
  2.  
  3. #define SIZE 100
  4. int Masiv[SIZE];
  5. int prom = 0;
  6. int input = 0;
  7. int value = 0;
  8.  
  9. void check() {
  10.     int checker;
  11.  
  12.     int Checking[SIZE];
  13.     printf("The amount of numbers is:%d\n", prom);
  14.  
  15.     for (checker = 0; checker < prom; checker++) {
  16.         printf("\nNumber you are looking for: ");
  17.         scanf("%d", &Checking[checker]);
  18.         printf("\n");
  19.         for (value = 0; value < prom; value++) {
  20.  
  21.  
  22.  
  23.             if (Checking[checker] == Masiv[value]) {
  24.  
  25.                 printf("The number matches\n");
  26.  
  27.             }
  28.             else { printf("There are no matching numbers\n "); }
  29.         }
  30.     }
  31. }
  32.  
  33. void MenuPrint() {
  34.  
  35.     printf("(1.)fill array:\n");
  36.     printf("(2.)Proverka na elemnt po stoinost:\n");
  37.     printf("(3.)Otpechatvane na masiv:\n");
  38.     printf("(4.)Elemen s nai malka suma ot systavqshtite go cifri:\n");
  39.     printf("(5.)Populvane na masiv:\n");
  40.     printf("(6.)Populvane na masiv:\n");
  41.     printf("(7.)Exit:\n");
  42. }
  43. void Array() {
  44.  
  45.     printf("Type down the count of numbers: ");
  46.  
  47.     scanf("%d", &prom);
  48.     printf("\n");
  49.     if (prom > 0 && prom < 32767) {
  50.  
  51.  
  52.     }
  53.     else {
  54.         input = 7;
  55.         printf("You can only type numbers!\n");
  56.     }
  57.     for (value = 0; value<prom; value++) {
  58.         printf("Number [%i]: ", value + 1);
  59.         scanf("%d", &Masiv[value]);
  60.  
  61.         if (Masiv[value] > 0 && Masiv[value] < 32767) {
  62.  
  63.  
  64.         }
  65.         else{ input = 7; }
  66.  
  67.     }
  68. }
  69. void printArray() {
  70.     int value;
  71.  
  72.     for (value = 0; value<prom; value++) {
  73.         printf("\n The numbers you chose:%d\n", Masiv[value]);
  74.  
  75.  
  76.  
  77.  
  78.     }
  79. }
  80. void SumOfDigits() {
  81.     int number, a, b, suma = 0;
  82.     int min = 0;
  83.     int i = 0;
  84.     number = Masiv[0];
  85.     while (number != 0) {
  86.         b = number % 10;
  87.         min = min + b;
  88.         number = number / 10;
  89.     }
  90.     for (i = 1; i < prom; i++)
  91.     {
  92.         number = Masiv[i];
  93.         a = number;
  94.         suma = 0;
  95.         while (a != 0) {
  96.             b = a % 10;
  97.             suma = suma + b;
  98.             a = a / 10;
  99.  
  100.         }
  101.         if (min > suma)
  102.         {
  103.             min = suma;
  104.         }
  105.     }
  106.     printf("\nMinimum is: %i\n", min);
  107.  
  108.  
  109.  
  110.  
  111. }
  112.  
  113.  
  114.  
  115.  
  116. void menu() {
  117.     FILE * fp;
  118.  
  119.     fp = fopen("file.txt", "w");
  120.     fprintf(fp, "%s %s %s %d", "I", "Am", "lubo", 2017);
  121.  
  122.     fclose(fp);
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. int main() {
  132.  
  133.     int promenliva;
  134.  
  135.     for (promenliva = 0; promenliva<SIZE; promenliva++) {
  136.  
  137.         Masiv[promenliva] = 0;
  138.     }
  139.  
  140.     MenuPrint();
  141.  
  142.     do
  143.     {
  144.         printf("\nSelect:");
  145.  
  146.  
  147.         scanf("%d", &input);
  148.  
  149.         if (input > 0 && input < 7) {
  150.  
  151.             switch (input) {
  152.  
  153.  
  154.             case 1:
  155.                 Array();
  156.                 break;
  157.             case 2:
  158.                 check();
  159.                 break;
  160.             case 3:
  161.                 printArray();
  162.                 break;
  163.             case 4:
  164.                 SumOfDigits();
  165.                 break;
  166.             case 5:
  167.  
  168.                 break;
  169.             case 6:
  170.  
  171.                 break;
  172.             case 7:
  173.  
  174.                 break;
  175.             }
  176.         }
  177.  
  178.         else {
  179.             input = 7;
  180.             printf("You cannot type diffrent than 1 to 7\n");
  181.         }
  182.     } while (input != 7);
  183.  
  184.     return 0;
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement