Форум » C/C++ для начинающих (C/C++ for beginners) » array with alternate even and odd » Ответить

array with alternate even and odd

learnernew79: hey, as discussed program for alternate even and odd numbers [pre2] #include<stdio.h> int main() { int a[]={9,8,8,7,6,5,14}; int n= sizeof(a) / sizeof(a[0]); int i,j; int t1; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[ i ]>a[ j ]) { t1=a[ i ]; a[ i ]=a[ j ]; a[ j ]=t1; } } } [/pre2]

Ответов - 26, стр: 1 2 All

Сыроежка: Pointers are also variables. When you deal with an array then 1) the array name in expressions is converted to pointer and 2) to traverse an array you have to use either pointers or indices.

learnernew79new: so, how to convert a given pointer to indices? is it possible? or vice vers?

Сыроежка: I already showed you early the function that uses indices instead of the pointers.


learnernew79new: yea, u did, just small confusions, any pdf u recommend for reading?

Сыроежка: You should read a book on C++ for beginners. I think you can find a list of books at SO. As for me then I do not read books for beginners so I can not say what books for beginners are published now.

learnernew79new: yea, thanx a lot for help. cleared so many doubts. nice meeting u, sir



полная версия страницы