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

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

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

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

Usingthe “String Type” functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length.The program shouldthen scramble the word by moving the middle character to the beginning of the word and output the new word.
حل آخر
PHP:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string word; int size;
    cout<<"Enter odd word : ";
    while(!(word.size()%2==1)){cin>>word;}
    size=word.size();
    word=word[size/2]+word.substr(0,size/2)+
        word.substr((size/2)+1,size-(size/2));
    cout<<endl<<word<<endl; return 0;
}
 
سؤال ..
طالبين برنامج نكتب برنامج فيه فنكشن ترتب .. و فكنشن تقرأ و اليوزر الي يدخل الأرقام .. و الفنكشن الثالثه بتطبع

السايز من وين بناخذ قيمته ؟! يعني احنا نحدد على كيفنا ؟
إيه تخلين اليوزر هو إلا يدخل عدد الأرقام إلا بيدخلها بعدين
PHP:
cout<<"enter how many number do u want to enter"; cin >>num;
 
سؤال ..
طالبين برنامج نكتب برنامج فيه فنكشن ترتب .. و فكنشن تقرأ و اليوزر الي يدخل الأرقام .. و الفنكشن الثالثه بتطبع

السايز من وين بناخذ قيمته ؟! يعني احنا نحدد على كيفنا ؟

انا ماشفت السؤال اللي تتكلمين عنه بس مخلال شرحش له

Function to sort
هذي بتكون كود جاهز ، يعني واحده من الطرق اللي تعلمتونهم

Function to read
هذي عشان اليوزر يدخل الأرقام من خلالها

Fucntion to print
بتطبع محتويات الArrya

بالنسبة للسايز طبعاً لازم بتدخلينهم كـ parameter في كل الfunctions اللي عندش


وطبعا بيقرأ الارقام بأستخدام الfunction مو من main

موفقين
نسالكم الدعاء
 
هلا ..

عندي سؤال في التتوريال ماعرف شنو المفروض الكود يصير حقة ..

اذا ابي اكتب فنكشن حق برنامج .. المفروض اول تكون الأري sorted .. ويبون ندخل نيو آيتيم فيها في مكانه الصحيح ..شنو الكود الي يخليها تسوي ادد لهاي الآيتيم ؟؟ :nosweat:
 
بس مكتوب ف السؤال (Use selection sort algorithm) و الي محطوط كان bubblesort

انا سويت مثله و double بس يطلع ليي ايرور

سويت السورت بهذي الطريقة و خليت الاريي double

ويش الخطأ :RpS_crying: :RpS_crying:

HTML:
void selectionSort(double list[ ], int length)
{
    int index;
    double smallestIndex;
    int minIndex;
    double temp;
 
    for (index = 0; index < length - 1; index++)
    {
            //Step a
        smallestIndex = index; 
 
        for (minIndex = index + 1; minIndex < length; minIndex++)
            if (list[minIndex] < list[smallestIndex])
                smallestIndex = minIndex; 
 
            //Step b
        temp = list[smallestIndex];
        list[smallestIndex] = list[index];
        list[index] = temp;
    }
}

1=>

كود:
[LEFT]
#include <iostream>
#include <string>
using namespace std;
void sortlist (double x[],int y)
{
    double z;
    for (int i=0;i<y;i++)
    {
        for (int j=i+1;j<y;j++)
        {
        if (x[i]<x[j])
        {
            z=x[i];
            x[i]=x[j];
            x[j]=z;
        }
        }
    }
}
void readList (double x[],int y)
{
     for(int i=0;i<y;i++)
     cin>>x[i];
}
void printList (double x[],int y)
{
     for(int i=0;i<y;i++)
     cout<<x[i]<<" ";
}
void printopFive (double x[],int y)
{
    double z;
    for (int i=0;i<y;i++)
    {
        for (int j=i+1;j<y;j++)
        {
        if (x[i]<x[j])
        {
            z=x[i];
            x[i]=x[j];
            x[j]=z;
        }
        }
    }
    for(int i=0;i<5;i++)
    cout<<x[i]<<" ";
}
     
int main()
{
    double quiz[10];
    int id;
    string name;
    cout<<"Enter Student ID: ";
    cin>>id;
    cout<<"Enter Student Name: ";
    cin>>name;
    cout<<"Enter quiz grades: ";
    readList(quiz,10);
    cout<<"\n\nReport\nID: "<<id<<"\nName: "<<name<<endl;
    cout<<"Grades (descending): ";
    sortlist(quiz,10);
    printList(quiz,10);
    cout<<"\nTop 5 grades: ";
    printopFive(quiz,10);
    cout<<endl;
    system("pause");
    return 0;
}
[/LEFT]
 
بس مكتوب ف السؤال (Use selection sort algorithm) و الي محطوط كان bubblesort

انا سويت مثله و double بس يطلع ليي ايرور

سويت السورت بهذي الطريقة و خليت الاريي double

ويش الخطأ :RpS_crying: :RpS_crying:

HTML:
void selectionSort(double list[ ], int length)
{
    int index;
    double smallestIndex;
    int minIndex;
    double temp;
 
    for (index = 0; index < length - 1; index++)
    {
            //Step a
        smallestIndex = index; 
 
        for (minIndex = index + 1; minIndex < length; minIndex++)
            if (list[minIndex] < list[smallestIndex])
                smallestIndex = minIndex; 
 
            //Step b
        temp = list[smallestIndex];
        list[smallestIndex] = list[index];
        list[index] = temp;
    }
}

عندك غلط بسيط " index & minindex " حولهم إلى " double " ... :whistling:
 
سؤال ..
طالبين برنامج نكتب برنامج فيه فنكشن ترتب .. و فكنشن تقرأ و اليوزر الي يدخل الأرقام .. و الفنكشن الثالثه بتطبع

السايز من وين بناخذ قيمته ؟! يعني احنا نحدد على كيفنا ؟

إذا كان قصدكم هذا السؤال ..
Write a C++ program that includes the following functions:


  1. A function named sortList that takes as parameters: an array of double and the array size. The function should sort the numbers in a descending order. Use bubble sort algorithm.


  1. A function named readList that takes as parameters: an array of double and the array size. The function should prompt the user to input the array data.


  1. A function named printList that takes as parameters: an array of double and the array size. The function should display the elements of the array.

Write a main program to test your functions.

الرقم تاخذه الفنكشن من الـ " main " والسؤال يبي برنامج إختبار للدوال يعني تخلون أي حاجه عشان تتأكدون من الإجابة
كود:
void sortlist (double x[],int y)
void readList (double x[],int y)
void printList (double x[],int y)
 
هلا ..

عندي سؤال في التتوريال ماعرف شنو المفروض الكود يصير حقة ..

اذا ابي اكتب فنكشن حق برنامج .. المفروض اول تكون الأري sorted .. ويبون ندخل نيو آيتيم فيها في مكانه الصحيح ..شنو الكود الي يخليها تسوي ادد لهاي الآيتيم ؟؟ :nosweat:

السؤال مو واضح بس اللي فهمته .. :RpS_huh:
- ترتيب المصفوفة
- البحث عن رقم بإستخدام
Binary search
- تغيير الرقم
 
حتى لو حولتهم ما يصير بعد تطلع اخطاء اعتفد الي داخل البراكت مال الاريي [] لازم integer من جذي تطلع اخطاء

:RpS_glare: :RpS_glare: :RpS_glare:


يطلع هذا الايرور

error C2108: subscript is not of integral type​

عندك غلط بسيط " index & minindex " حولهم إلى " double " ... :whistling:
 
حتى لو حولتهم ما يصير بعد تطلع اخطاء اعتفد الي داخل البراكت مال الاريي [] لازم integer من جذي تطلع اخطاء

:RpS_glare: :RpS_glare: :RpS_glare:


يطلع هذا الايرور

error C2108: subscript is not of integral type​

مسامحة .. :nosweat:
المفروض كلهم "
int "
كود:
int index;
int smallestIndex;
int minIndex;
 
سلام عليكم
ممكن أحد أشوف لي الأسايمنت صح لو خطأ
السؤال:
String Type
Using the "String Type" functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length. The program should then scramble the word by moving the middle character to the beginning of the word and output the new word.

Example:

[TABLE="width: 566"]
[TR]
[TD="bgcolor: #ffffff"]Enter a word (odd – length):
Book
Invalid input, the word should be of an odd length.
Enter a word (odd – length):
Program
The scrambled word = gProram
[/TD]
[/TR]
[/TABLE]

الجواب :
#include <iostream>
#include <string>
using namespace std;
int middle(string y);

if(str1.length()/2 !=0)
{

y = x+str1.supstr(0, (str1.length()/2)-1)+str1.supstr(str1.length()/2)+1), str1.length();
cout<<"The scrambled word ="<<y<<endl;
}
else

cout<<"Invalid input, the word should be of an odd length."<<endl;

}
int main()
{
string str1=" ";
cin>>str1;
cout<< "Enter a word : "<<endl;
middle(string y);
return 0;
}



يا ريت بسرعة لأن أمبي أطرشه الحين
​
 
عندي هوم اسايمنت م و مو راضي ينفتح من البلاك بورد .. شاسوي :tears:
 
سلام عليكم
ممكن أحد أشوف لي الأسايمنت صح لو خطأ
السؤال:
String Type
Using the "String Type" functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length. The program should then scramble the word by moving the middle character to the beginning of the word and output the new word.

Example:

[TABLE="width: 566"]
[TR]
[TD="bgcolor: #FFFFFF"]Enter a word (odd – length):
Book
Invalid input, the word should be of an odd length.
Enter a word (odd – length):
Program
The scrambled word = gProram
[/TD]
[/TR]
[/TABLE]

الجواب :
#include <iostream>
#include <string>
using namespace std;
int middle(string y);

if(str1.length()/2 !=0)
{

y = x+str1.supstr(0, (str1.length()/2)-1)+str1.supstr(str1.length()/2)+1), str1.length();
cout<<"The scrambled word ="<<y<<endl;
}
else

cout<<"Invalid input, the word should be of an odd length."<<endl;

}
int main()
{
string str1=" ";
cin>>str1;
cout<< "Enter a word : "<<endl;
middle(string y);
return 0;
}



يا ريت بسرعة لأن أمبي أطرشه الحين
​

؟؟ أحد ارد علي رحم الله والديكم:99:
 
غلط , حتى السبلنق بعد
 
أنزين في وين عاد الخطأ السبلنق مو مشكلة بعدلها بس الباقي
 
إذا كان قصدكم هذا السؤال ..

Write a C++ program that includes the following functions:



  1. A function named sortList that takes as parameters: an array of double and the array size. The function should sort the numbers in a descending order. Use bubble sort algorithm.




  1. A function named readList that takes as parameters: an array of double and the array size. The function should prompt the user to input the array data.




  1. A function named printList that takes as parameters: an array of double and the array size. The function should display the elements of the array.


Write a main program to test your functions.




الرقم تاخذه الفنكشن من الـ " main " والسؤال يبي برنامج إختبار للدوال يعني تخلون أي حاجه عشان تتأكدون من الإجابة
كود:
void sortlist (double x[],int y)
void readList (double x[],int y)
void printList (double x[],int y)


عدل هذا هو السؤال بس بعد مو راضي يضبط وياي ! يعني لما اسويه دباق لازم كل مره في ايرورز :RpS_crying:
 
كود:
[LEFT]#include <iostream>
#include <string>
using namespace std;


void sortlist (double list[],int size)
{
    double z;
    for (int i=0;i<size;i++)
    {
        for (int j=i+1;j<size;j++)
        {
        if (list[i]<list[j])
        {
            z=list[i];
            list[i]=list[j];
            list[j]=z;
        }
        }
    }
}
void readList (double list[],int size)
{
     for(int i=0;i<size;i++)
     cin>>list[i];
}
void printList (double list[],int size)
{
     for(int i=0;i<size;i++)
     cout<<list[i]<<" ";
}




int main()
{
    double list[10];
    
    cout<<"Enter valus: ";
    readList(list,10);
    cout<<endl;
     cout<<"the valus after sorting : ";
    sortlist(list,10);
    printList(list,10);
    


    system("pause");
    return 0;


}[/LEFT]


صح هذا ؟؟ ما عرفت اسوي ان اليوزر هو الي يدخل السايز فخليت السايز ع كيفي :nosweat:
 
كود:
[LEFT]#include <iostream>
#include <string>
using namespace std;


void sortlist (double list[],int size)
{
    double z;
    for (int i=0;i<size;i++)
    {
        for (int j=i+1;j<size;j++)
        {
        if (list[i]<list[j])
        {
            z=list[i];
            list[i]=list[j];
            list[j]=z;
        }
        }
    }
}
void readList (double list[],int size)
{
     for(int i=0;i<size;i++)
     cin>>list[i];
}
void printList (double list[],int size)
{
     for(int i=0;i<size;i++)
     cout<<list[i]<<" ";
}




int main()
{
    double list[10];
    
    cout<<"Enter valus: ";
    readList(list,10);
    cout<<endl;
     cout<<"the valus after sorting : ";
    sortlist(list,10);
    printList(list,10);
    


    system("pause");
    return 0;


}[/LEFT]


صح هذا ؟؟ ما عرفت اسوي ان اليوزر هو الي يدخل السايز فخليت السايز ع كيفي :nosweat:

إجابة صحيحة .. :smile2:
بالنسبة للمصفوفة ما يصير نخلي حجمها متغير مثل :

[list[
x لازم يكون عدد أو ثابت ...= const x
والسؤال طالب برنامج عشان نختبر الإجابة فمايضر لو حطينا أرقام من عندنا ..
:rolleyes2:

مثل الأسايمنت مالنا .. :RpS_lol:
 
سلام عليكم
ممكن أحد أشوف لي الأسايمنت صح لو خطأ
السؤال:
String Type
Using the "String Type" functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length. The program should then scramble the word by moving the middle character to the beginning of the word and output the new word.

Example:

[TABLE="width: 566"]
[TR]
[TD="bgcolor: #ffffff"]Enter a word (odd – length):
Book
Invalid input, the word should be of an odd length.
Enter a word (odd – length):
Program
The scrambled word = gProram[/TD]
[/TR]
[/TABLE]

الجواب :
#include <iostream>
#include <string>
using namespace std;
int middle(string y);

if(str1.length()/2 !=0)
{

y = x+str1.supstr(0, (str1.length()/2)-1)+str1.supstr(str1.length()/2)+1), str1.length();
cout<<"The scrambled word ="<<y<<endl;
}
else

cout<<"Invalid input, the word should be of an odd length."<<endl;

}
int main()
{
string str1=" ";
cin>>str1;
cout<< "Enter a word : "<<endl;
middle(string y);
return 0;
}



يا ريت بسرعة لأن أمبي أطرشه الحين
​

؟؟ أحد ارد علي رحم الله والديكم

هذا السؤال حليناه في الصفحات اللي قبل ..

كود:
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    int mid;
    cout<<"Enter a word (odd \- length):\n";
    cin>>str;
    while ((str.length()%2));
    {
        cout<<"\nInvalid input, the word should be of an odd length.\n";
        cout<<"Enter a word (odd \- length):\n";
        cin>>str;
    }
    mid=str.length()/2;
    str=str[mid]+str.substr(0,mid)+str.substr(mid+1);
    cout<<"\nThe scrambled word = "<<str<<endl;
    system("pause");
    return 0;
}
 
عودة
أعلى أسفل