diff --git a/C/program-36/program.c b/C/program-36/program.c new file mode 100644 index 00000000..9d823305 --- /dev/null +++ b/C/program-36/program.c @@ -0,0 +1,29 @@ +/* + +You are given a sorted (either in the increasing or in the decreasing order) sequence of numbers, ending with a -1. You can assume that are at least two numbers before the ending -1. + +Let us call the sequence x0 x1 ... xn -1. + +You have to output the number of distinct elements in the sorted sequence. + +Kindly do not use arrays in the code. + +*/ + +#include +#include + +int main() +{ + int count=0,n=0,m; + while(n!=-1) + { + scanf("%d",&n); + if(m!=n) count++; + else continue; + m=n; + + } +printf("%d",count-1); + return 0; +}