Created
October 28, 2010 20:25
-
-
Save erenon/652257 to your computer and use it in GitHub Desktop.
probaNZH f0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct ablak { | |
int a; | |
int b; | |
int c; | |
int d; | |
char e[50]; | |
}; | |
/** | |
* a feladat | |
*/ | |
void f1() { | |
short s[100]; | |
int i; | |
for(i=0;i<100;i++) { | |
s[i] = 0; //ez a sor nem szükséges, de nélküle memszemetet olvasunk | |
printf("%hd\n", s[i]); | |
} | |
} | |
/** | |
* b feladat | |
*/ | |
void f2() { | |
int szam = 20; | |
int m; | |
m = 1; | |
m = m<<4; | |
m = ~m; | |
printf("4: %d\n", szam & m); | |
} | |
/** | |
* c feladat | |
*/ | |
int f3(double t[], int m) { | |
int i,count=0; | |
for(i=0;i<m;i++){ | |
if(t[i] < 0) { | |
count++; | |
/* gyakran mondjak, hogy elhagyhatok a zarojelek, | |
* de ne hagyjuk el oket: | |
* http://stackoverflow.com/questions/359732/why-is-it-considered-a-bad-practice-to-omit-curly-braces | |
*/ | |
} | |
} | |
return count; | |
} | |
/** | |
* d feladat | |
*/ | |
int f4() { | |
double *p; | |
p = (double *)malloc(sizeof(double)); | |
if(p == NULL) { | |
printf("fail\n"); | |
return 1; | |
} | |
*p = 3.14; | |
printf("%lg\n", *p); | |
free(p); | |
p = NULL; | |
return 0; | |
} | |
int main() { | |
//c feladat tesztelesehez | |
double t[] = {1,2,-3,4,5}; | |
//e feladat | |
struct ablak gomb; | |
f1(); | |
f2(); | |
printf("%d\n", f3(t, 5)); | |
f4(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment