-
Notifications
You must be signed in to change notification settings - Fork 0
/
numofvar.c
89 lines (82 loc) · 1.09 KB
/
numofvar.c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<stdio.h>
#include<ctype.h>
#include<string.h>
char a[30],b[30],d[30][30]={' '},e[30],dup[30][30]={' '};
int r=0,c=0,i,j=0,k,len,count,size;
void check()
{
int i,j,k=0;
count=r;
for(i=0;i<r;i++)
{
strcpy(dup[i],d[i]);
for(j=i+1;j<r;j++)
{
if(!strcmp(d[i],d[j]))
{
count--;
break;
}
else
{
strcpy(dup[i],d[i]);
}
}
}
}
int main()
{
printf("\nEnter The Equation::");
scanf("%s",a);
len=strlen(a);
for(i=0;i<len;i++)
{
if(isalpha(a[i]) || isdigit(a[i]))
{
b[j]=a[i];
j++;
}
else
{
b[j]='_';
j++;
}
}
b[j]='\0';
for(i=0;b[i]!='\0';i++)
{
if(isalpha(b[i]))
{
d[r][0]=b[i];
for(k=0;(b[i]!='_')&&(b[i]!='\0');k++)
{
d[r][k]=b[i];
i++;
}
d[r][k]='\0';
r++;
}
}
check();
/*printf("\n%s\n",b);
for(i=0;i<r;i++)
{
for(k=0;k<30;k++)
{
printf("%c ",d[i][k]);
}
printf("\n");
}
*/
/*printf("\nAfter Removal::\n");
for(i=0;i<count;i++)
{
for(k=0;k<30;k++)
{
printf("%c ",dup[i][k]);
}
printf("\n");
}*/
printf("\nNumber Of Variable is::%d\n",count);
return 0;
}