LABORATORIYA ISHI-1
Guruh:_______
Bajardi:_____FIO_________
1-Labaratoriya ishi
STATIK MA’LUMOTLAR TUZILMASINI TADQIQ QILISH.
55-variant
Savol: ____________________________________________________________
Dastur:
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.print("n=");
int n=in.nextInt();
int a[]=new int[n];
for (int i = 0; i a[i]=in.nextInt();
}
int s=0;
for (int i = 0; i < n; i++) {
if (i%2==0){
System.out.println(a[i]);
s+=a[i];
}
}
System.out.println(s);
}
}
Run:
n=5
2 5 4 8 6
2
4
6
12
Process finished with exit code 0
NATIJA:
Do'stlaringiz bilan baham: |