Part 7
- 2. Farsi e-learning series
&'& ! " # $ !%
#include <iostream.h>
#include <conio.h>
int calc(int [],int dim);
void revmatrix( int [],int dim);
void main()
{
int matrix[1000];
int dim,temp;
double leftsum,rightsum;
cout<<" PLEASE ENTER MATRIX DIMANTION : ";
cin>>dim;
cout<<"nnn";
for( int i = 0;i<( dim*dim );i ++ )
{
cout<<"ENTER ELEMAN : ";
cin>>temp;
matrix[i] = temp;
clrscr();
cout<<" PLEASE ENTER MATRIX DIMANTION : "<<dim;
cout<<"nnn";
}//for i
if ( dim > 2 )
{
leftsum = calc( matrix , dim );
cout<<"LEFTSUM of the matrix = "<< leftsum <<"nn";
revmatrix( matrix , dim );
rightsum = calc( matrix ,dim );
cout<<"RIGHTSUM of the matrix = "<< rightsum <<"nnnnnn" ;
cout<<" ( DETERMINAN OF THE MATRIX = "<< leftsum - rightsum<<" )";
}
else
cout<<" ( DETERMINAN OF THE MATRIX = "<<(matrix[0] * matrix[3] - matrix[1]
* matrix[2])<<" )";
getch();
}//end main
/////////////////calc function//////////
int calc( int matrix[ ], int dim )
{
int sum = 0, bul, x = 1;
for( int l = 0; l<( dim*dim );l += ( dim+1 ) )//ghotr asli
x *= matrix[l];
sum = x;
x = 1;
for( int c = 1;c<dim;c ++ )
{
bul=c;
for( int m = 0;m<dim;m ++ )
{
if( ( bul+1 )%dim != 0 )
{
x *= matrix[bul];
- 3. Farsi e-learning series
bul +=( dim + 1 );
}
else
{
x = x * matrix[bul];
bul += 1;
}
}//for m
sum += x;
x = 1;
}//for c
return sum;
}
////////////////////revmatriv determinan
void revmatrix(int matrix[ ],int dim)
{
int end,temp,counter;
for( int t = dim-1;t <= dim*dim;t = t + dim )
{
end=t;
counter = end -( dim-1 );
while( end > counter )
{
temp = matrix[end];
matrix[end] = matrix[counter];
matrix[counter] = temp;
++ counter;
-- end;
}
}
}
/ 0 ,- -123 * % * % $4 ) " %* * 5 67 * ,89 : ; " , 0 " % ) * + ,- , .
=< ,. % % % * ,89 : %* * 5 ,- , 0 % )
#include <iostream.h>
int main()
{
int i,j;
double a[512],b;
cout<<”How many content do you want to enter ?:”;
cin >>i;
cout<<”Enter “<<i<<” contents :”;
for(j=0;j<i;j++)
cin>> a[j];
cout<<”Enter a keyword to search in your array : “;
cin >> b;
(
- 4. Farsi e-learning series
for(j=0;j<i;j++)
{
if (a[j]==b)
{
break;
}
}
if (j>=i)
cout << "not found" << endl;
else
cout <<”Hurray !! your searched content is in this row :
“<< j << endl;
return 0;
}
>
- 5. Farsi e-learning series
,8
J% 9 3 7 # !3 8- - ,8 % % I% 3 C ;! 8- - D E ,- @7 , 05 3F . ,GH = @A$. %% 5 B . ,8
I% - % ,4. 8- - , 8- -D E III * D F
I 3 QRSS O P ) ,- 3 MN 8- - ,8 K8. @ LF
% 3 % % X . 5 D E Y$ . 3 ,8 ,- 8- -B .5 , 0" % % TUVVW D F L
T U V V W MN
I -" - , 8- - ,8 " # P #* F . !3 [A 5 $A % MN 8- - Z * %
I @9 : 8- - , 8- - D E # ! 3 Y @9 : - D E % F $8 " ) . #0 # ! 3 Y 8- - ,8 " ) /89 :
b% - % `87 * a* 5 # ! 3 ,8 $8 C ;! # 5 % ^)9 ,8 _ ]
Char ali[26]=”WWW.MRH.IR”;
Char aida[26]={ ‘m’ , ‘a’ , ‘j’ , ‘i’ , ‘d’ }
I $ % f. Y ,)Hc " Y * de& Y @_ c*% / $8A. ! 3 Z * % ,-
I Y$ - 3 c " B*
-12 ,8 + * ,89 : ,8 " ,- $A , .
#include <iostream.h>
int main()
{
char a[64];
int i,c;
cout<<"Enter a strings:"<<endl;
cin>>a;
for(int i=0; a[i]!='0'; i++);
cout<<"Size of string : " <<i<<endl;
return 0;
}
I% 3 5D E J -12 .0 + * ,89 : ,8 3; % f. g - /$ ,- Y$A 3; ! Y$ h :
#include <iostream.h>
void size(char a[],char b[])
{
int i;
for(i=0; a[i]!='0'; i++);
cout<<"Size of string : " <<i<<endl;
}
int main()
{
char a[64];
int i,c;
cout<<"Enter a strings:"<<endl;
cin>>a;
size(a);
return 0;
}
- 36- 3_* % 3 *% * ,89 : ,8 ) *% ,- $A , . (
?
- 6. Farsi e-learning series
#include <iostream.h>
int main()
{
char a[64],b[64];
cout<<"Enter 2 strings:"<<endl;
cin>>a;
cin>>b;
int i=0;
do{
a[i]=b[i];
}while(b[i++]!='0');
a[i]='0';
return 0;
}
I $ % f. E9 / 0D ! 8j$ 3 0 * 8K / !
8A d I ,. h 8- % 3 Z ! %J . 0 a5 / E9 0 % ,- 3 / ! - )!
I . 3 C ;! lmne&oIT ,. h 8- % 8A ,8 -, k ,- J ,. h 8- Z ! /
IY 5 % P 3 #0 , * , ,- J % % $A p 9 3A . , . # 5 4% J# 5/ % ,8 $8 ,- J 6A + ,8G. /
k 9 7 q$r ! Z !
smne&oIT I $ , ,8 " + smnVU&bt]
smne&oIT I - 3 36- 4 % % ,8 smnduvbtwx]
smne&oIT I - 3 36- 8- - & % ;! , - c 4% % ,8 smn&duvbtwxw&]
smne&oIT I -3 GF ,8 ) smnnUybt]
smne&oIT I -3 E8 Y , K.0 * ,89 : ,8 *% smndtmbtwx]
smne&oIT I ,8 % 8- - & - c z c ,8 ,G { I - 3 E8 Y , ,8 *% smn&dtmbtwxw&]
smne&oIT 3 J% 8: } 3 *% : J . % : 3 % 8: } 3_* : * - 3 ,j ) ,8 *% smnd|ubtwx]
I .% : 3 N .% : * .% :
smne&oIT I .% : 3 g . ,f$8. * -3 ,A ) Y ,8 *% 5 * 8- - Q smn&d|ubtwxw&]
i
- 7. Farsi e-learning series
D !
I - 36- 3_* % 3 *% * ,89 : ,8 *% ,- $A 3; ! ,G 3 ; I $ G Z ! , ! (
I .% : .% : * . % : N J % 8: } 3 *% : I . % : J % 8: } 3_* : * % $4 ,8 *% ,- $A 3; !
I % 3_* % *% ,8 @ K. % * % - ,A ) K.0 g / ! . J 1 2 - + J ,89 : ,8 *% ,- $A , . (
b ,89 : %* * 5 & ] I % f. ,8 * 8- - & * / ! ,- $A , . >
I - E8 4 , K.0 * ,89 : ,8 *% Z ! " 5 % `87 ,- $A , . ?
b ,89 : %* * 5 & ] I % ,f$8. % K.0 5 ,8 & * % - E8 Y , ,8 *% 3; ! 5 % `87 ,- $A , . i
I - GF ,8 ) " 3; ! 5 % `87 ,- $A , . ~
"# $ % & !
., /,& ! '( ) *+ , - ,
www.mrh.ir
www.majidonline.com
(•? 1 0
2 3 ,& , 45 6 789 ':) ; <
~