Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class task5 {
- static int[] m={1,0,1,0,1};
- static int i,j,er;
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- /*
- * Здесь теоритически можно вводить массив из 0 и 1
- m= new int[100];
- while(sc.hasNextInt()) {
- m[i]=sc.nextInt();
- i++;
- }
- */
- i=m.length-1;
- if (m[0]==0){
- for(j=0;j<i;j+=2){
- if (m[j]!=0) {
- er++;
- break;
- }
- }
- for(j=1;j<=i;j+=2){
- if (m[j]!=1) {
- er++;
- break;
- }
- }
- }
- else {
- for(j=0;j<i;j+=2) {
- if (m[j]!=1) {
- er++;
- break;
- }
- }
- for(j=1;j<i;j+=2){
- if (m[j]!=0) {
- er++;
- break;
- }
- }
- }
- if (er==0) {
- System.out.print("Строго чередуются");
- }
- else {
- System.out.print("Не чередуются строго");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement