عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 30-04-2010, 02:35 AM   #535

Mr.Ahmad

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

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

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

المشاركة الأصلية كتبت بواسطة هوتميلكوم مشاهدة المشاركة
السلام عليكم ورحمة الله

بصراحة منتدى جداً رائع واستفدت بشكل كبير من المعلومات لإنني مبتدئة بالسي وأعاني من مشاكل
اتمنى منكم مساعدتي في حل هذا السؤال ولكم جزيل الشكر

numeric address for computers on the international network internet are composed of four parts, separated by periods ,of the form
xx.yy.zz.mm
where xx,yy,zz ,and mm are positive integers. Locally,computers are usually known by a nickname as well. you are designing a program to process a list of internet addresses, identifying all pairs of computers from the same locality.
create a structure type called address_t wit components for the four integers of an internet address and a fifth component in which to store an associated nickname of 10 characters. your program should read a list of up to 100 addresses and nicknames terminated by a sentinel address of all zeros and a sentinel nickname.


Sample Data
111.22.3.44 platte
555.66.7.88 wabash
111.22.5.66 green
0.0.0.0 none
the program should display a list of messages identifying each pair of computers from the same locality___that is , each pair of computers with matching values in the first two components of the address. In the messages, the computers should be identified by their nicknames.

رجاء من يستطيع مساعدتي في حله بأقرب وقت ممكن
وسأكون شاكرة جداً له

عندي امتحان فيه ولم استطع الحل
وان شاء الله مجهودكم في ميزان حسناتكم
وعليكم السلام ورحمة الله وبركاته .

على حسب ما فهمت السؤال ,, هذا حلي له :

كود 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;
}
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");
 
 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 -> ");
  
scan_address_forFind(&temp);
  if (
== 1)
   
check_Number(list,temp.xx,temp.yy,temp.zz,temp.mm); 
 }







بالتوفيق .

 

توقيع Mr.Ahmad  

 

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

 

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