-
Notifications
You must be signed in to change notification settings - Fork 18
/
Find if a given pattern appears in both the input strings at same postions..cs
62 lines (58 loc) · 1.57 KB
/
Find if a given pattern appears in both the input strings at same postions..cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication112
{
class Program
{
static void Main(string[] args)
{
int i, j, L1,L2,c1=0,c2=0,p=0,k=0,p1=0;
Console.WriteLine("Enter the First String");
string a = Console.ReadLine();
Console.WriteLine("Enter the Second String");
string b = Console.ReadLine();
L1 = a.Length;
L2 = b.Length;
int[] pos = new int[10];
int[] pos1 = new int[10];
for (i = 0; i < L1; i++)
{
if (a[i] == '-')
{
pos[p] = i;
p++;
c1++;
}
}
for (j = 0; j < L2; j++)
{
if (b[j] == '-')
{
pos1[p1] = j;
p1++;
c2++;
}
}
for (p = 0; p < c1; p++)
{
for (p1 = 0; p1 < c2; p1++)
{
if (pos[p] == pos1[p1])
{
k = k + 2;
Console.WriteLine("{0}==={1}", pos[p], pos1[p1]);
}
}
}
Console.WriteLine("\n");
if (k == (c1 + c2))
{
Console.WriteLine("true");
}
Console.ReadLine();
}
}
}