موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

ITCS112 - ITCS104 - ITCS102 للفصل الصيفي 2014 - 2015

غلط :whistling: , عدلت في برنامجي وصار مثل ما قلت لازم احط ال size بدل ما احطه فاضي ولازم اسوي i++ بدل i+=2 :smile2:

يصير لان سريع سريع ، كان عندي اسايمنت طوويل

بس وين الغلط ؟
خليت مثل مثالك


PHP:
      int list[10]={1,0,0,5,1,0,0};
    int length=7;

وعادي يشتغل

عموما اهم شي استفدت ولو بالشي القليل :)
 
Write a function called deletelastoccurence that takes as parameters an aaray of string an item and the array size. The function should delete the last occurence of the item. Write a main function to test your function
 
ممكن مساعده في السؤال اللي فوق
 
Write a function called deletelastoccurence that takes as parameters an aaray of string an item and the array size. The function should delete the last occurence of the item. Write a main function to test your function

PHP:
#include <iostream>
#include <string>
using namespace std;

void deletelastoccurence (string list[],int & size,string item)
{
    int loc;
    for (int i=0;i<size;i++)
    {
        for (int j=0;j<size;j++)
        {
            if (list[j]==item)
            loc=j;
        }
    }
    for (int i=loc;i<size-1;i++)
    list[loc]=list[loc+1];
    size--;
}

int main()
{
    string list[]={"A","V","D","F","R","E","G","E","R","R","C","V","G","S","A","B"};
    int size=16;
    deletelastoccurence (list,size,"A");
    for (int i=0;i<size;i++)
    cout << list[i] << " ";
    
}
 
اذا امبي اكتب في البرنامج ان الرقم odd او even شلون اعبر عنهم ؟
 
من يعرف يسوي الفنكشن
Write a function named removeExtraBlanks that takes two parameters: an array of characters (Sentence), and the number of characters in the array (Length), which is passed by reference. The function should remove all extra blanks in Sentence, i.e. for each two consecutive blanks, the function should remove the second blank character and decrement length accordingly. The function should also return the number of extra blanks removed from Sentence.
For example, If Length=10 and the content of Sentence before calling the function is:
[TABLE="align: left"]
[TR]
[TD][/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[TD]7
[/TD]
[TD]8
[/TD]
[TD]9
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]




Then, after calling the function: Length=7 and Sentence should be as follows:

[TABLE="align: left"]
[TR]
[TD][/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]


In addition, the function should return 3 (i.e. 3 blanks were removed)
 
يا جماع البلاك بورد ما عم تفتح معي.. حده عنده مشكله ؟؟؟
لازم ابعت الاسايمنت .. :(
 
من يعرف يسوي الفنكشن
PHP:
#include<iostream>
using namespace std;

int removeExtraBlanks(char list[] , int &length )
{ int loc , count=0 ;
    for(int i=0 ; i<length ; i++){
    if(list[i]==' ' && list[i+1]==' '){
    loc=i;
    for(int j=loc ; j<length-1 ; j++)
    list[j]=list[j+1];
    length--;
    i--;
    count++;
    }
}
  return count;
}
int main()
{
    char arr[15]={'A',' ',' ','R',' ','T',' ',' ','G','H',' ',' ','F','F'};
    int len=14 , c ;
   c=removeExtraBlanks(arr,len);
   
   for(int i=0 ; i<len ; i++)
    cout<<arr[i];
    cout<<endl;
    
    cout<<"Counter = "<<c<<endl;
    
    system("pause");
    return 0;
    }
 
  • Like
التفاعلات: ha
اذا امبي اكتب في البرنامج ان الرقم odd او even شلون اعبر عنهم ؟

تعبر عنهم بهالطريقة
number%2=0 يعني رقم even
number%2=1 يعني رقم odd
 
الحل
PHP:
#include<iostream>
using namespace std;

int removeExtraBlanks(char list[] , int &length )
{ int loc , count=0 ;
    for(int i=0 ; i<length ; i++){
    if(list[i]==' ' && list[i+1]==' '){
    loc=i;
    for(int j=loc ; j<length-1 ; j++)
    list[j]=list[j+1];
    length--;
    i--;
    count++;
    }
}
  return count;
}
int main()
{
    char arr[15]={'A',' ',' ','R',' ','T',' ',' ','G','H',' ',' ','F','F'};
    int len=14 , c ;
   c=removeExtraBlanks(arr,len);
   
   for(int i=0 ; i<len ; i++)
    cout<<arr[i];
    cout<<endl;
    
    cout<<"Counter = "<<c<<endl;
    
    system("pause");
    return 0;
    }

اذا في خطأ لاسمح الله خبروني



لآ صح مشاءالله عليك
جربته واشتغل


بس اذا عندك وقت بعدين تشرح لي شلون سويت الفنكشن



ومشكور ما قصرت تعبنآك
 
PHP:
#include<iostream>
using namespace std;

int removeExtraBlanks(char list[] , int &length )
{ int loc , count=0 ;
    for(int i=0 ; i<length ; i++){
    if(list[i]==' ' && list[i+1]==' '){
    loc=i;
    for(int j=loc ; j<length-1 ; j++)
    list[j]=list[j+1];
    length--;
    i--;
    count++;
    }
}
  return count;
}
int main()
{
    char arr[15]={'A',' ',' ','R',' ','T',' ',' ','G','H',' ',' ','F','F'};
    int len=14 , c ;
   c=removeExtraBlanks(arr,len);
   
   for(int i=0 ; i<len ; i++)
    cout<<arr[i];
    cout<<endl;
    
    cout<<"Counter = "<<c<<endl;
    
    system("pause");
    return 0;
    }


ما شاء الله عليييك

اني الفنكشن اللي سويتها complicated وبعد مو شغالة عدل

مشكوور ما تقصر
 
الحمد لله توي مكمل منه :whistling: :whistling:

عقب ما جنني و مساعدات شوي :bleh:

سويته cin :RpS_glare:


لآ صح مشاءالله عليك
جربته واشتغل


بس اذا عندك وقت بعدين تشرح لي شلون سويت الفنكشن



ومشكور ما قصرت تعبنآك
 
الحمد لله توي مكمل منه :whistling: :whistling:

عقب ما جنني و مساعدات شوي :bleh:

سويته cin :RpS_glare:
على البركة ..

المهم هذا شرح بسيط للبرنامج ..
في البداية نحتاج فور لوب عشان نبحث عن المسافات في الـ "
array "
كود:
for(int i=0 ; i<length ; i++)[COLOR=#a9a9a9]
[/COLOR]
بعدين الشرط اللي يطلع لينا انه في مسافتين ورى بعض
كود:
if(list[i]==' ' && list[i+1]==' ')[COLOR=#a9a9a9]
[/COLOR]
في داخل الشرط نسوي لوب تبدي من النقطة اللي شفنا فيها المسافتين
كود:
for(int j=i ; j<length-1 ; j++)[COLOR=#a9a9a9]
[/COLOR]
داخل الفور لوب نبدل المواقع الأحرف و نخليهم يرجعون .. << :nosweat:
كود:
list[j]=list[j+1];
خطوة مهمة نرجع قيمة الفور لوب الأوليه عشان يبحث مرة ثانية في مثل المكان + ننقص الطول مال الـ " array "
كود:
length--;
i--;
طبعا ما ننسى الكونتر عشان يحسب كم مرة دخلنا الشرط وحذفنا المسافة ..
كود:
c++;[COLOR=#a9a9a9]
[/COLOR]
 
عودة
أعلى أسفل