Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/ipc.h>
- #include <sys/msg.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <string.h>
- #include <sys/types.h>
- int sum;
- int mno;
- int roz;
- int dev;
- void suma ()
- {
- sum=a+b
- };
- void mnozenie ()
- {
- mno=a*b
- };
- void roznica ()
- {
- roz=a-b
- };
- void dzielenie ()
- {
- dev=a/b
- };
- void wyswietlanie ()
- {
- };
- typedef struct {
- long type;
- char tresc[1000];
- } komu;
- void nadawca(int kolejka){
- komu k;
- k.type=1;
- strcpy(k.tresc, "ala ma kota");
- msgsnd(kolejka,&k , sizeof(komu),IPC_NOWAIT);
- }
- void odbiorca(int kolejka){
- komu k;
- msgrcv(kolejka, &k, sizeof(komu),1,0);
- printf("%s",k.tresc);
- msgctl(kolejka,IPC_RMID,NULL);
- }
- int main(){
- pthread_t threads [5];
- pthread_create(&threads[0], NULL, suma, 0);
- pthread_create(&threads[1], NULL, roznica, 0);
- pthread_create(&threads[2], NULL, mnozenie, 0);
- pthread_create(&threads[3], NULL, dzielenie, 0);
- pthread_create(&threads[4], NULL, wyswietlanie, 0);
- int num;
- int number[10];
- char c;
- int i = 0;
- while((c = getchar()) !=EOF)
- {
- if(c == ' ' || c == '\n')
- {
- number[i++] = '\0";
- num = atoi(number);
- printf("%d\n", num);
- i=0;
- }
- else
- {
- number[i++] = c;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement