עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

הגדרת טיפוס ב typedef ב C

Featured Replies

  • תגובות 126
  • צפיות 11.1k
  • נוצר
  • תגובה אחרונה
פורסם
  • מחבר

שאר הקוד זה: set.c


#include "set.h"
set* checkname();
int checkbit1(); set* Initialize();
void read_set(); void print_set(); void union_set(); void intersect_set(); void sub_set(); void halt();

 

ככה הוא נראה רק שהפונקציות כתובות שם....אני לא יכול לעשות העתק הדבק מאבונטו..דרך vm ware

פורסם
  • מחבר



#include "set.h"

void setbit(set *s, int i){

char b=0;

int j=i/8;

i=i%8;

b=b|1;

b=b<<i;

((*s)[j])=((*s)[j])|b;

}

 

int checkbit(set *s,int num){

char b=0;

int i=num/8;

num=num%8;

B|=((*s)[i]);

b=b>>num;

if((b&1)==1){

return 1;

}else{

return 0;

}

}

set* checkname(){

char *a,*b;

int i=0;

a=sets[i].name;

b=strtok(NULL," ,");

while(strcmp(b,a)!=0&&i<=11){

i++;

a=sets[i].name;

}

if(strcmp(b,a)!=0){

printf("No such set\n");

return 0;

}else{

return sets[i].s;

}

return 0;

}

set* Initialize(set *s){

for(int i=0;i<=15;i++){

*s[i]=0;

}

return s;

}

 

 

 

 

 

 

 

void read_set(){

int x=0;

char *z;

set *s;

s=checkname();

Initialize(s);

z=strtok(NULL,",");//find num char

x=strtol(z,NULL,0);//convert to int

while(x!=-1&&x<=127){//-1=end of string

setbit(s,x);//set the bit

z=strtok(NULL,",");

if(z==NULL){

printf("plese enter -1 to end the set\n");

return;

}

x=strtol(z,NULL,0);

}

if(x>127){

printf("%d is out of range\n",x);

return;

}

}

void print_set(){

set *b;

int k=0,j=0;

b=checkname();//b-point to the group

for(int i=0;i<128;i++){

if((checkbit(b,i))==1){

printf("%d,",i);

k=1;

j++;

if(j==15){

printf("\n");

}

}

}

if(k==0){

printf("the group is empty\n");

}

printf("\n");

}

void union_set(){

set *a,*b,*c;

a=checkname();

b=checkname();

c=checkname();

Initialize(c);

for(int i=0;i<=15;i++){

(*c)[i]=((*a)[i])|((*b)[i]);

}

return;

}

 

 

void intersect_set(){

set *a,*b,*c;

a=checkname();

b=checkname();

c=checkname();

Initialize(c);

for(int i=0;i<=15;i++){

(*c)[i]=((*a)[i])&((*b)[i]);

}

return;

}

void sub_set(){

set *a,*b,*c;

a=checkname();

b=checkname();

c=checkname();

Initialize(c);

for(int i=0;i<=15;i++){

(*c)[i]=((*a)[i])&(((*a)[i])^((*b)[i]));

}

return;

}

void halt(){

exit(EXIT_SUCCESS);

}



פורסם
  • מחבר

נכון לעכשיו זאת הבעיה שלי

multiple definition of 'sets'

לפי מה שהבנתי בחיפוש בגוגל שזה מאתחל אותו פעמיים או משהו כזה.

פורסם
  • מחבר

הייתי צריך להוריד את

include set.h מה main

פורסם

ראשית, חדל מלעשות דאבל פוסט. אם יש לך משהו חדש להוסיף, השתמש בכפתור העריכה.

תעזור לנו לעזור לך. מה זה ה-main? קובץ שלישי?

אתה צריך לוודא שאתה מבצע include רק פעם אחת לכל קובץ, בשביל זה יש את ה-include guards. אתה יודע מהו שלב ה-linkage?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.