Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h.>
  4.  
  5.  
  6. int eis ()
  7. {
  8.     int N;
  9.     do
  10.     {
  11.     printf ("Εισάγετε το πλήθος των διαφορετικών ακεραίων (7-49): \n");
  12.     scanf ("%d",&N);
  13.     }
  14.     while ( N <= 6 || N > 49 );
  15.     return N;
  16. }
  17.  
  18.  
  19. int * pin1(int N)
  20. {
  21.     int ar, i, j, check;
  22.     int *a;
  23.     a=(int *)malloc(N*sizeof(int));        
  24.     for (i=1;i<=N;i++)
  25.     {  
  26.         do
  27.         {
  28.             check = 1;
  29.             do
  30.             {
  31.                 if (check == 0)
  32.                     printf ("Ο αριθμός έχει ήδη εισαχθεί. Εισάγετε ξανά τον %dο αριθμό (1-49): ", i);
  33.                 else
  34.                     printf ("Εισάγετε τον %dο αριθμό (1-49): ", i);
  35.                 check = 1;
  36.                 scanf("%d", &ar);
  37.                 for (j=1; j<=i; j++)
  38.                 {
  39.                     if (ar== *(a+j))
  40.                     check = 0;
  41.                 }
  42.             }
  43.         while (check == 0);            
  44.         }
  45.         while (ar<0 || ar>=50 );
  46.             *(a+i)=ar;
  47.     }
  48.     return a;
  49. }
  50.  
  51.  
  52.  
  53. int main()
  54. {
  55.     int N;
  56.     int *pin;
  57.     system ("chcp 1253");
  58.     N = eis();
  59.     *pin = pin1(N);
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement