Professional Documents
Culture Documents
C++ Exercises
C++ Exercises
Electronics
.Engineering Dept
1
:
>#include <stdio.h
#define N 6
)(void main
{
;int a[N][N]={ 72,17, 36, 441, 297, 12 }, i, j, n
)for(i=1; i<N; i++
{
)for (j=i; j<N; j++
;]a[i][j]=a[0][j-i
;n=i
)for (j=0; j<i; j++
{
;]a[i][j]=a[0][N-n
;n--
}
}
)for (i=0;i<N;i++
{
)for (j=0;j<N;j++
;)]printf("%d ",a[i][j
;)"printf(" \n
}
{
.1 ) (.
.2 "?
:
.1 - ) <- , (0
"
.
.2 :
72 17 36 441 297 12
12 72 17 36 441 297
297 12 72 17 36 441
441 297 12 72 17 36
36 441 297 12 72 17
17 36 441 297 12 72
hr@sce.ac.il
08-6475662 :
08- :
6475661
Electrical and
.Engineering Dept
Electronics
. , 11 - :
{Arr[11] = { 1, 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , 10
,
. .
:
#include <stdio.h>
#define N 11
void InsertNumber( int A[], int num);
/****************************************
*
MAIN
*
****************************************/
void main()
{
int A[N] = {1, 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , 10};
int temp=10, num, i;
printf("Enter your number");
scanf("%d",&num);
///////////////// Insert a new number into the array
///////////////
InsertNumber(A,num);
/* print the output */
printf ("\nThe new array is: \n");
for (int j=0; j<N; j++)
printf ("%d ", A[j]);
}//end of main
///////////////// Insert a new number into the array
void InsertNumber( int A[], int num)
{
int i, temp=10;
///////////////
08- :
6475661
08-6475662 :
hr@sce.ac.il
Electrical and
Electronics
.Engineering Dept
3
. , 10 - :
{Arr[10] = { 1, 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , 10
,
.
:
#include <stdio.h>
#define N 10
void SwapArray(int A[]);
/****************************************
*
MAIN
*
****************************************/
void main()
{
int A[10] = { 1, 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , 10};
int temp, j, i;
SwapArray(A); /* calling to the function, to swap the values */
/* print the output */
printf ("\nThe new array is: \n");
for (j=0; j<10; j++)
printf ("%d ", A[j]);
}//end of main
void SwapArray(int A[])
{
int i,j,temp=0;
for(i=0,j=9; i<5; i++, j--)
{
temp = A[i]; /* swap the values */
A[i]= A[j];
A[j]=temp;
}
}
08- :
6475661
08-6475662 :
hr@sce.ac.il