Write A Program To Find The Saddle Point of The Matrix.: C++ Practical
Write A Program To Find The Saddle Point of The Matrix.: C++ Practical
Write A Program To Find The Saddle Point of The Matrix.: C++ Practical
Program-1
void main()
{
int a[10][10],i,j;
clrscr();
cout<<"Enter the matrix elements\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>a[i][j];
}
}
saddlepoint(a,3,3);
getch();
}
small[j]=a[i][j];
}
}
}
max=big[0];
for(i=1;i<row;i++)
{
if(big[i] > max)
{
max = big[i];
}
}
min=small[0];
for(j=1;j<col;j++)
{
if(small[j] < min)
{
min = small[j];
}
}
if(max==min)
{
cout<<"\n\n\n\t\t\tTHE SADDLE POINT IS -->"<<max<<endl;
}
else
{
cout<<"\n\n\n\nNO SADDLE POINT";
}
getch();
return 0;
}
Output:
Program-2
Write a program to find the position of a substring within string (using pointers).
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
void locate(char *,char *);
void main()
{
char s1[50],s2[20];
clrscr();
cout<<"\nEnter the main String:";
gets(s1);
cout<<"\nEnter the substring to be searched in the main string:";
gets(s2);
locate(s1,s2);
getch();
}
void locate(char *mainstr,char *substr)
{
int i,j,flag=0,a,pos;
int l1=strlen(mainstr);
int l2=strlen(substr);
for(i=0;i<=l1-l2;i++)
{
if(mainstr[i]==substr[0])
{
pos=i;j=0;
while(mainstr[i]==substr[j])
{
j++;
i++;
}
if(j>=strlen(substr))
{
flag=1;
break;
}
}
}
if(flag)
cout<<"\nSub string is present at position "<<pos+1;
else
Output:
arrial
narrow:14above 15 below