الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

لم تكتمل الفرحة

مغلق
بدأه ابونادر في 11 أبريل 2002 · 0 رد · 254 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1

هذا البرنامج يدخل اسماء طلاب ومعدلات و...

ويرتب البيانات يواسطة bubble sort وinsertion sort وفي ال bubble sort شغال 100%100 لان البيانات تتحرك كجزء واحد ولكن في الinsertion sort لاتتحرك كجزء واحد. ارجوكم عدلوا لي هذة النقطه في ال وinsertion sort وقد حولت وكانت كحاولاتي فاشلة‍‍!!!??

#include

#include

#include

#define max 500

int nos;

struct student

{

char studentname[40];

int credittaken;

int creditearned;

float totalgradepoint;

};

void menw();

void name();

void bubble_sort();

void bubble_sort1();

void bubble_sort2();

void bubble_sort1_credittaken();

void bubble_sort1_creditearned();

void bubble_sort1_totalgradepoint();

void bubble_sort2_credittaken();

void bubble_sort2_creditearned();

void bubble_sort2_totalgradepoint();

//////////////////////////////////////////////////////////////////

void insertion_sort();

void insertion_sort1();

void insertion_sort2();

void insertion_sort1_credittaken();

void insertion_sort1_creditearned();

void insertion_sort1_totalgradepoint();

void insertion_sort2_credittaken();

void insertion_sort2_creditearned();

void insertion_sort2_totalgradepoint();

struct student temp;

struct student st[max];

int m,i;

void main(void)

{

cout<<"ENTER NUMBER OF STUDENT: ";

cin>>nos;

for (int i = 0;i< nos;i++)

{

cout << "Student Name("<

cin>>st.studentname;

cout<<"credittaken("<

cin>> st.credittaken ;

cout << "creditearned("<

cin>>st.creditearned;

cout<<"otalgradepoint("<

cin>> st.totalgradepoint ;

}

menw();

cout<<"nt**************************************************************"

<<"nt"<

<<"nt**************************************************************"<

for (i = 0;i< nos;i++)

{

cout<<"nt"<

cout<<"nnn";

}

}//end main()

///////////////////////

void menw() //menw

{

int chose;

cout<<"tt**************************************"<

cout<<"tt* enter number 1 for bubble sort *"<

cout<<"tt* enter number 2 for insertion sort *"<

cout<<"tt**************************************"<

cin>>chose;

switch(chose)

{

case(1):bubble_sort();break;

case(2):insertion_sort();break;

default:cout<<"number error "<<"n";menw();

}

}

////////////////////////bubble sort//////////

void bubble_sort()

{

int chose;

cout<<"tt**************************************"<

cout<<"tt* enter number 1 for increase *"<

cout<<"tt* enter number 2 for decreased *"<

cout<<"tt**************************************"<

cin>>chose;

switch(chose)

{

case(1):bubble_sort1();break;

case(2):bubble_sort2();break;

default:cout<<"number error"<<"n";bubble_sort();

}

}

void bubble_sort1()

{

int chose;

cout<<"tt ****************************************"<<"n";

cout<<"tt * enter number 1 for credittaken *"<<"n";

cout<<"tt * enter number 2 fro creditearned *"<<"n";

cout<<"tt * enter number 3 for totalgradepoint *"<<"n";

cout<<"tt ****************************************"<<"n";

cin>>chose;

switch(chose)

{

case(1):bubble_sort1_credittaken();break;

case(2):bubble_sort1_creditearned();break;

case(3):bubble_sort1_totalgradepoint();break;

default:cout<<"number error"<<"n";bubble_sort1();

}

}

void bubble_sort2()

{

int chose;

cout<<"tt ****************************************"<<"n";

cout<<"tt * enter number 1 for credittaken *"<<"n";

cout<<"tt * enter number 2 fro creditearned *"<<"n";

cout<<"tt * enter number 3 for totalgradepoint *"<<"n";

cout<<"tt ****************************************"<<"n";

cin>>chose;

switch(chose)

{

case(1):bubble_sort2_credittaken();break;

case(2):bubble_sort2_creditearned();break;

case(3):bubble_sort2_totalgradepoint();break;

default:cout<<"number error"<<"n";bubble_sort1();

}

}

void bubble_sort1_credittaken()

{

for(int j=1;j

{

for ( int i = 0 ; i < nos-1 ; i++)

if (st.credittaken > st[i+1].credittaken )

{

temp = st;

st = st[i+1];

st[i+1] = temp;

};

}

}

void bubble_sort1_creditearned()

{

for(int j=1;j

{

for ( int i = 0 ; i < nos-1 ; i++)

if (st.creditearned > st[i+1].creditearned )

{

temp = st;

st = st[i+1];

st[i+1] = temp;

};

}

}

void bubble_sort1_totalgradepoint()

{

for(int j=1;j

{

for ( int i = 0 ; i < nos-1 ; i++)

if (st.totalgradepoint > st[i+1].totalgradepoint )

{

temp = st;

st = st[i+1];

st[i+1] = temp;

};

}

}

void bubble_sort2_credittaken()

{

for(int j=1;j

{

for ( int i = 0 ; i < nos-1 ; i++)

if (st.credittaken < st[i+1].credittaken )

{

temp = st;

st = st[i+1];

st[i+1] = temp;

};

}

}

void bubble_sort2_creditearned()

{

for(int j=1;j

{

for ( int i = 0 ; i < nos-1 ; i++)

if (st.creditearned < st[i+1].creditearned )

{

temp = st;

st = st[i+1];

st[i+1] = temp;

};

}

}

void bubble_sort2_totalgradepoint()

{

for(int j=1;j

{

for ( int i = 0 ; i < nos-1 ; i++)

if (st.totalgradepoint < st[i+1].totalgradepoint )

{

temp = st;

st = st[i+1];

st[i+1] = temp;

};

}

}//////end bubble sort

//////////////inesrtion sort //////////////////

void insertion_sort()

{

int chose;

cout<<"tt*****************************************"<<"n";

cout<<"tt* enter number 1 for increase *"<<"n";

cout<<"tt* enter number 2 for decreased *"<<"n";

cout<<"tt*****************************************"<<"n";

cin>>chose;

switch(chose)

{

case(1):insertion_sort1();break;

case(2):insertion_sort2();break;

default:cout<<"number error"<<"n";insertion_sort();

}

}

void insertion_sort1()

{

int chose;

cout<<"tt ****************************************"<<"n";

cout<<"tt * enter number 1 for credittaken *"<<"n";

cout<<"tt * enter number 2 fro creditearned *"<<"n";

cout<<"tt * enter number 3 for totalgradepoint *"<<"n";

cout<<"tt ****************************************"<<"n";

cin>>chose;

switch(chose)

{

case(1):insertion_sort1_credittaken();break;

case(2):insertion_sort1_creditearned();break;

case(3):insertion_sort1_totalgradepoint();break;

default:cout<<"number error"<<"n";insertion_sort1();

}

}

void insertion_sort2()

{

int chose;

cout<<"tt ****************************************"<<"n";

cout<<"tt * enter number 1 for credittaken *"<<"n";

cout<<"tt * enter number 2 fro creditearned *"<<"n";

cout<<"tt * enter number 3 for totalgradepoint *"<<"n";

cout<<"tt ****************************************"<<"n";

cin>>chose;

switch(chose)

{

case(1):insertion_sort2_credittaken();break;

case(2):insertion_sort2_creditearned();break;

case(3):insertion_sort2_totalgradepoint();break;

default:cout<<"number error"<<"n";insertion_sort2();

}

}

void insertion_sort1_credittaken()

{

int in,out;

for( out=1; out

{

int temp = st[out].credittaken;

in = out;

while( in>0 && st[in-1].credittaken >= temp)

{

st[in]= st[in-1];

--in;

}

st[in].credittaken = temp;

}

}

void insertion_sort1_creditearned()

{

int in,out;

for( out=1; out

{

int temp = st[out].creditearned;

in = out;

while( in>0 && st[in-1].creditearned >= temp)

{

st[in].creditearned= st[in-1].creditearned;

--in;

}

st[in].creditearned = temp;

}

}

void insertion_sort1_totalgradepoint()

{

int in,out;

for( out=1; out

{

float temp = st[out].totalgradepoint;

in = out;

while( in>0 && st[in-1].totalgradepoint >= temp)

{

st[in].totalgradepoint = st[in-1].totalgradepoint;

--in;

}

st[in].totalgradepoint = temp;

}

}

void insertion_sort2_credittaken()

{

int in,out;

for( out=1; out

{

int temp = st[out].credittaken;

in = out;

while( in>0 && st[in-1].credittaken <= temp)

{

st[in].credittaken = st[in-1].credittaken;

--in;

}

st[in].credittaken = temp;

}

}

void insertion_sort2_creditearned()

{

int in,out;

for( out=1; out

{

int temp = st[out].creditearned;

in = out;

while( in>0 && st[in-1].creditearned <= temp)

{

st[in].creditearned= st[in-1].creditearned;

--in;

}

st[in].creditearned = temp;

}

}

void insertion_sort2_totalgradepoint()

{

int in,out;

for( out=1; out

{

float temp = st[out].totalgradepoint;

in = out;

while( in>0 && st[in-1].totalgradepoint <= temp)

{

st[in].totalgradepoint = st[in-1].totalgradepoint;

--in;

}

st[in].totalgradepoint = temp;

}

}//end inertion sort

هذا الموضوع مغلق.

مواضيع مشابهة