عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 07-05-2010, 10:13 PM   #547

Mr.Ahmad

عضو هيئة تدريس

الصورة الرمزية Mr.Ahmad

 
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
افتراضي رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

المشاركة الأصلية كتبت بواسطة هوتميلكوم مشاهدة المشاركة
السلام عليكم ورحمة الله وبركاته
أخي Mr Ahmad
إذا ممكن تحللي السؤال نفسو بحيث تكتب عناوين الشبكات
ويقوم البرنامج بإخبارك إذا كانت at the same local network
أو not the same local network
حيث أن الشرط لأن تكون الشبكات(at the same local network)
هو تساوي قيمة أول ثلاث خانات xxx

جزاك الله خيراً ان شاء الله..
كود PHP:
#include <stdio.h>
#include <conio.h>
#include <string.h>

typedef struct 
{
    
int xx,yy,zz,mm;
    
char name[10];
address_t;

int scan_address (address_t *x)
{
    
int status;
    
status scanf("%d.%d.%d.%d %s",&x->xx,&x->yy,&x->zz,&x->mm,&x->name);
    if (
status == 5) return 1;
    return 
status 0;
}

int scan_address_forFind (address_t *x)
{
    
int status;
    
status scanf("%d.%d.%d.%d",&x->xx,&x->yy,&x->zz,&x->mm);
    if (
status == 4) return 1;
    
printf("Wrong Entry !\n\n");
    return 
status 0;
}

int read (address_t *x)
{
    
int i 1,status,index 0;
    
address_t temp;
    
status scan_address(&x[0]);
    while (
status != && 100)
    {
        
status scan_address(&x[i]);
        
temp x[i];
        if (
temp.xx == && temp.yy == && temp.zz == && temp.mm == 0)
        {
            
index i
            
printf("\n* OK *\n");
            break;
        }
        
i++;
    }
    return 
index;
}

int isSame_local_Network (address_t *xint index)
{
    
int i;
    for (
i=0i< (index-1); i++)
    {
        if (
x[i].xx != x[i+1].xx) return -1;
    }
    return 
1;
}

void check_Nicknames (address_t *list,char *x)
{
    
int i;
    for (
i=0i<100i++)
    {
        if (
strncmp(x,list[i].name,10) == 0)
        {
            
printf("Found : %d.%d.%d.%d\n",list[i].xx,list[i].yy,list[i].zz,list[i].mm);
            break;
        }
        else if (list[
i].xx == && list[i].yy == && list[i].zz == && list[i].mm == 0)
        {
            
printf("Not Found !\n");
            break;
        }
    }
    
printf("\n");
}

void check_Number (address_t *list,int x,int y,int zint m)
{
    
int i;
    for (
i=0i<100i++)
    {
        if (list[
i].xx == && list[i].yy == && list[i].zz == && list[i].mm == m)
        {
            
printf("Found : %s\n",list[i].name);
            break;
        }
        else if (list[
i].xx == && list[i].yy == && list[i].zz == && list[i].mm == 0)
        {
            
printf("Not Found !\n");
            break;
        }
    }
    
printf("\n");
}

int main()
{
    
int i 1,index 0;
    
int status;
    
char find[10] = "";
    
address_t list[100],temp;
    
printf("Enter Data : (Example: 111.22.5.66 green) \n------------------------------------------\n");
    
status read(list);
    
printf("\n-------------------------\n");
    if (
isSame_local_Network(list,status) != -1printf("At the same local network\n");
    else 
printf("Not the same local network \n");
    
/*
    while (1)
    {
        //Find By Nicknames
        printf("Enter Nicknames to Find Number -> ");
        scanf("%s",&find);
        check_Nicknames(list,find);

        //Find By Number
        printf("Enter Number to Find Nicknames -> ");
        i = scan_address_forFind(&temp);
        if (i == 1)
            check_Number(list,temp.xx,temp.yy,temp.zz,temp.mm);    
    }
    */



 

توقيع Mr.Ahmad  

 

سبحان الله وبحمد ,,, سبحان الله العظيم
الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه .
اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.

 

Mr.Ahmad غير متواجد حالياً   رد مع اقتباس