LightOj 1000 - Greetings from LightOJ - Solution in C
LightOJ Online Judge Solution 1000 | Beginner
LightOj Problem Link - http://www.lightoj.com/volume_showproblem.php?problem=1000
Problem Name: 1000 Greetings from LightOJ
Problem Number : LightOj- 1000
Online Judge : LightOj Online Judge Solution
Category: Beginner
Solution Language : C
LightOj Online Judge Solution 1000 Code in C:
#include <stdio.h>
int main() {
int n, i = 1, x, y;
scanf("%d", &n);
while(n){
scanf("%d%d", &x,&y);
printf("Case %d: %d\n", i, x+y);
i++;
n--;
}
return 0;
}
Demonstration:
Take a variable for number of test case - n
scanf("%d", &n);
Then Make a while loop upto that number. Then again take two values and print that just adding the values.
int n, i = 1, x, y;
while(n){
scanf("%d%d", &x,&y);
printf("Case %d: %d\n", i, x+y);
i++;
n--;
}
Increment i and decrements n. i for print the case no.
Run LightOj 1000 code live and test the result:
Tags: LightOj Online Judge Solution, LightOj - Beginner
No comments:
Post a Comment