Posts

Showing posts with the label EASY

CODECHEF - RECTANGL

Problem Code : RECTANGL Problem : Rectangle Platform : Codechef Type : Online Language : C Link : CODECHEF 1: //submitted 2: //https://www.codechef.com/JAN18/problems/RECTANGL 3: #include <stdio.h> 4: void func() 5: { 6: int arr[4]; 7: scanf("%d",&arr[0]); 8: scanf("%d",&arr[1]); 9: scanf("%d",&arr[2]); 10: scanf("%d",&arr[3]); 11: int i,j,temp; 12: for(i=0;i<=2;i++) 13: { 14: for(j=0;j<=2-i;j++) 15: { 16: if(arr[j]<arr[j+1]) 17: { 18: temp=arr[j]; 19: arr[j]=arr[j+1]; 20: arr[j+1]=temp; 21: } 22: } 23: } 24: //printf("%d-%d-%d-%d--\n",arr[0],arr[1],arr[2],arr[3]); 25: if(arr[0]==arr[1] && arr[2]==ar...

CODECHEF - CIELAB

Problem Code : CIELAB Problem : Ciel and A-B Problem Platform : Codechef Language : C Level : Easy Link : CODECHEF 1: //submitted 2: //https://www.codechef.com/problems/CIELAB 3: #include <stdio.h> 4: #include<stdlib.h> 5: #include <string.h> 6: void func() 7: { 8: int a,b; 9: scanf("%d",&a); 10: scanf("%d",&b); 11: int ans=a-b; 12: //for +1 13: if((ans+1)%10!=0) 14: { 15: printf("%d\n",ans+1 ); 16: return; 17: } 18: //for -1 19: printf("%d\n",ans-1 ); 20: } 21: int main() 22: { 23: int cases=1; 24: // scanf("%d",&cases); 25: while(cases--) 26: { 27: func(); 28: } 29: return 0; 30: }