URI Online Judge | 1073
Even Square
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Read an integer N. Print the square of each one of the even values from 1 to N including N if it is the case.
Input
The input contains an integer N (5 < N < 2000).
Output
Print the square of each one of the even values from 1 to N, as the given example.
Be carefull! Some language automaticly print 1e+006 instead 1000000. Please configure your program to print the correct format setting the output precision.
Input Sample | Output Sample |
6 | 2^2 = 4 4^2 = 16 6^2 = 36 |
Solution 1073 in Java language:
- import java.util.Scanner;
- public class URI_1072 {
- public static void main(String[] args) {
- int N , X, in = 0, out = 0;
- int interval_start =10,interval_end =20 ;
- Scanner input =new Scanner(System.in);
- N =input.nextInt();
- for (int i = 1; i <= N; i++) {
- X =input.nextInt();
- if (X >= interval_start && X <= interval_end) {
- in += 1;
- }else {
- out += 1;
- }
- }
- System.out.print(in+" in\n"+out +" out\n");
- }
- }
URI Solution 1073 in C
- #include <stdio.h>
- int main()
- {
- int n, i;
- scanf("%d", &n);
- for ( i = 1; i <= n; ++i)
- {
- if(i % 2 == 0){
- printf("%d^2 = %d\n", i,(i * i));
- }
- }
- return 0;
- }
URI Solution 1073 in C++
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- for (int i = 1; i <= n; ++i)
- {
- if(i % 2 == 0){
- cout << i << "^2 = " << (i * i) << endl;
- }
- }
- return 0;
- }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks