Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions C/program-36/program.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdlib.h>

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;
}