Guest User

Untitled

a guest
Feb 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Scanner input = new Scanner(System.in); // Объявляем Scanner
  3. System.out.println("Enter array length: ");
  4. int size = input.nextInt(); // Читаем с клавиатуры размер массива и записываем в size
  5. int array[] = new int[size]; // Создаём массив int размером в size
  6. System.out.println("Insert array elements:");
  7. /*Пройдёмся по всему массиву, заполняя его*/
  8. for (int i = 0; i < size; i++) {
  9. array[i] = input.nextInt(); // Заполняем массив элементами, введёнными с клавиатуры
  10. }
  11. System.out.print ("Inserted array elements:");
  12. for (int i = 0; i < size; i++) {
  13. System.out.print (" " + array[i]); // Выводим на экран, полученный массив
  14. }
  15. System.out.println();
  16. }
  17.  
  18. public static void main(String[] agrs)
  19. {
  20. int[] a = new int[7];
  21. int i = 0;
  22. Scanner in = new Scanner(System.in);
  23.  
  24.  
  25. for (int element : a)
  26. {
  27.  
  28. System.out.print("Введите " + (i + 1) + "-й элемент массива: ");
  29. a[i] = in.nextInt();
  30.  
  31. System.out.println(a[i] + " - ");
  32.  
  33. i++;
  34. }
  35.  
  36. for (int element : a)
  37.  
  38. System.out.print(element + " ");
  39.  
  40.  
  41. }
  42.  
  43. public static void main(String[] agrs)
  44. {
  45. int[] a = new int[7];
  46. int i = 0;
  47. Scanner in = new Scanner(System.in);
  48.  
  49. for (int element : a)
  50. {
  51.  
  52. System.out.print("Введите " + (i + 1) + "-й элемент массива: ");
  53. a[i] = in.nextInt();
  54.  
  55. System.out.println(a[i] + " - ");
  56.  
  57. i++;
  58. }
  59.  
  60. System.out.println(Arrays.toString(a));
  61. }
  62.  
  63. import java.util.Scanner;
  64. public class PerBor_Mas {
  65.  
  66. public static void main(String[] args) throws InterruptedException {
  67. int n = vvod.nextInt();
  68. int[] A = new int[n];
  69. int k = vvod.nextInt();
  70.  
  71. Scanner vvod = new Scanner(System.in);
  72. System.out.println("Введите длину одномерного массива");
  73.  
  74.  
  75. System.out.println("Введите первый элемент массива");
  76.  
  77. System.out.println("Водится массив");
  78.  
  79. for (int i = 0; i < n; i++) {
  80. System.out.print(A[i] + k + "t");
  81. k++;
  82. }
  83. System.out.println(" ");
  84.  
  85. }
  86. }
Add Comment
Please, Sign In to add comment