Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.   char buf[256];
  7.   char s[256];
  8.   int a, b, c, t;
  9.  
  10.   printf("1. feladat\n");
  11.   printf("\'Sikerult\' az \"elso\" feladat.\n\n");
  12.  
  13.   printf("2. feladat\n");
  14.   printf("Elso szam: ");
  15.   fgets(buf,sizeof(buf),stdin);
  16.   a = atoi(buf);
  17.   printf("Masodik szam: ");
  18.   fgets(buf,sizeof(buf),stdin);
  19.   b = atoi(buf);
  20.   if(a > b)
  21.   {
  22.     t = a;
  23.     a = b;
  24.     b = t;
  25.   }
  26.   printf("Harmadik szam: ");
  27.   fgets(buf,sizeof(buf),stdin);
  28.   c = atoi(buf);
  29.   t = 0;
  30.   if(b > c)
  31.   {
  32.     if(a > c) t = a; else t = c;
  33.   }
  34.   else t = b;
  35.   printf("A kozepso szam erteke: %d.\n\n",t);
  36.  
  37.   printf("3. feladat\n");
  38.   printf("A vizsgalando szam: ");
  39.   fgets(buf,sizeof(buf),stdin);
  40.   a = atoi(buf);
  41.   if((a % 7) > 0)
  42.     printf("A szam nem oszthato 7-tel maradek nelkul.\n\n");
  43.   else printf("A szam oszthato 7-tel maradek nelkul.\n\n");
  44.  
  45.   printf("4. feladat\n");
  46.   printf("A vizsgalando szam: ");
  47.   fgets(buf,sizeof(buf),stdin);
  48.   a = atoi(buf);
  49.   sprintf(s,"%d",a);
  50.   if(strlen(s) == 2)
  51.     printf("Elso szamjegy: %c\nMasodik szamjegy: %c\n\n",buf[0],buf[1]);
  52.   else printf("A bemenet nem egy ketjegyu szam volt.\n\n");
  53.  
  54.   printf("ENTER utan befejezodik a program futasa.\n");
  55.   getchar();
  56.   return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement