2011-03-15, 11:22 PM
|
#7
|
بيانات اضافيه [
+
]
|
رقم العضوية : 1
|
تاريخ التسجيل : Sep 2008
|
أخر زيارة : 2025-02-03 (07:35 PM)
|
المشاركات :
37,159 [
+
] |
التقييم : 13489
|
الدولهـ
|
الجنس ~
|
MMS ~
|
SMS ~
|
|
لوني المفضل : Blue
|
|
رد: نبضات رهين الشوق
حل سؤال input 500 numbers in array ; find the highest occurrence of x
#include <iostream.h>
#include <stdio.h>
int main()
{
int a[500] ;
int c ,o , u , n ,t ,x;
for(c=0;c<500;c++){
cin>>a[c];}
cout<<" Enter number to find ";
cin>>x;
for(o=499;o>=0;o--){
if(a[o]==x){
n=o;
}
}
cout<<" the highest occurrence is "<<n;
g***har();
return 0;
}
+
حل سؤال input 100 numbers in array ;transpose the array I,e make the last element the first and the first element the last .
#include <iostream.h>
#include <stdio.h>
int main()
{
int a[100] ;
int i , d , g ,t , r;
for(i=0;i<100;i++){
cin>>a[i];}
for(t=99,d=0;d<50;d++,t--){
r=a[d];
a[d]=a[t];
a[t]=r;
}
for(g=0;g<100;g++){
cout<<endl<<a[g];}
g***har();
return 0;
}
حل السؤال العاشر اممم بصراحه مالقيت له حل ولا اعرف احله
عشان ما توهق معك 
وهذا حل السؤال 12 اللي هو sort an array of 100 numbers .
الحل كالتالي
#include <iostream.h>
#include <stdio.h>
int main()
{
int a[100] ;
int i ,j , d , temp ;
// this section for input##
cout<<" Enter 100 numbers \n";
for(i=0;i<100;i++){
cin>>a[i]; }
// this section for sort array##
for(j=0;j<100;j++){
for(d=j+1;d<100;d++){
if(a[j]<a[d]){
temp=a[j];
a[j]=a[d];
a[d]=temp;
}}}
// this section for come out##
cout<<"\n the sort by largest is \n";
for(j=0;j<100;j++){
cout<<a[j]<<endl;
}
g***har();
return 0;
}
|
|
|