URI Online Judge Solution 1113 Ascending and Descending using C Programming Language.
Read an undetermined number of pairs of integer values. Write a message for each pair indicating if this two numbers are in ascending or descending order.
Input
The input file contains several test cases. Each test case contains two integer numbers X and Y. The input will finished when X = Y.
Output
For each test case print “Crescente”, if the values X and Y are in ascending order, otherwise print “Decrescente”.
Input Sample | Output Sample |
5 4
7 2 3 8 2 2 |
Decrescente
Decrescente Crescente |
Solution using C :
#include <stdio.h>
int main() {
while(1)
{
int X,Y;
scanf("%d%d",&X,&Y);
if(X==Y)
break;
if(X<Y)
printf("Crescente\n");
else
printf("Decrescente\n");
}
return 0;
}
int main() {
while(1)
{
int X,Y;
scanf("%d%d",&X,&Y);
if(X==Y)
break;
if(X<Y)
printf("Crescente\n");
else
printf("Decrescente\n");
}
return 0;
}
Comments
Post a Comment