راعية الألتيما Posted ديسمبر 5, 2005 Report Share Posted ديسمبر 5, 2005 لو سمحتوا ابي حل اسايمنت 5 حق السي اس 101 السؤال هو 4.15 use asingle array to solve the following problem read in 10 numbers each of wich is between 10 and 100, inclusive. as each number is read , print it only if it is not a duplicate of the a number already read . provide for the"worst case" in which all 10 numbers are different . at tha end you shouid print all the elements of the array مشكورين وما تقصرون Quote Link to comment Share on other sites More sharing options...
miney Posted ديسمبر 5, 2005 Report Share Posted ديسمبر 5, 2005 #include <iostream> using std::cout; using std::endl; using std::cin; #include <iomanip> using std::setw; int main() { const int SIZE = 20; int a[ SIZE ] = { 0 }; int subscript = 0; int duplicate; int value; cout << "Enter 20 integers between 10 and 100:\n"; for ( int i = 0; i < SIZE; ++i ) { duplicate = 0; cin >> value; for ( int j = 0; j < subscript; ++j ) if ( value == a[ j ] ) { duplicate = 1; break; } // end if if ( !duplicate ) a[ subscript++ ] = value; } // end for cout << "\nThe nonduplicate values are:\n"; for ( i = 0; a[ i ] != 0; ++i ) cout << setw( 4 ) << a[ i ]; cout << endl; return 0; } // end main Quote Link to comment Share on other sites More sharing options...
راعية الألتيما Posted ديسمبر 6, 2005 Author Report Share Posted ديسمبر 6, 2005 مشكورة اختي ما قدصرتي عساح على القوة Quote Link to comment Share on other sites More sharing options...
راعية الألتيما Posted ديسمبر 6, 2005 Author Report Share Posted ديسمبر 6, 2005 اختي انتي متأكدة منه لانه اعتقد انه مو صح لان الاوت بوت مة نفسه الي في الورقة ياريت اذا احد عنده حل ثاني يعطيني اياه وما تقصرون Quote Link to comment Share on other sites More sharing options...
miney Posted ديسمبر 6, 2005 Report Share Posted ديسمبر 6, 2005 #include<stdio.h> int main() { int i,j,a[20],x=1; for (i=0;i<20;i++) { printf("Enter a number between 10 & 100:"); scanf("%d",& a); while (a<10 || a>100) { printf("\nEnter a number again (10-100):"); scanf("%d",& a); } for (j=0;j<i;j++) { if (a[j]!=a) x=1; else { x=2; break; } } if(x==1) printf("%d\n",a); } return 0; } Quote Link to comment Share on other sites More sharing options...
راعية الألتيما Posted ديسمبر 8, 2005 Author Report Share Posted ديسمبر 8, 2005 اختي مسامحة بس ليش ما يرضه يطلع عندي الاوت بوت نفسه الي عندي في الورقة لو سمحتوا محد عنده حل ثاني ساااعدوني الله يخليكم يوم الاحد آخر يوم تسليمه الي عنده حل ثاني يحطه لي ما تقصرون Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.