Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class petla2 : MonoBehaviour
  6. {
  7. int[] tab = new int[20];
  8.  
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12.  
  13.  
  14. {
  15. for (int i = 0; i < 20; i++)
  16.  
  17. {
  18. int a = Random.Range(0, 200);
  19.  
  20.  
  21. tab[i] = a;
  22.  
  23.  
  24. int b = a * a;
  25. if (b % 2 == 0)
  26. Debug.Log("kwadrat " + a + " jest parzysty i wynosi " + a * a);
  27. else
  28. {
  29. Debug.Log("kwadrat " + a + " jest nieparzysty i wynosi " + a * a);
  30.  
  31. }
  32. }
  33. int[] tab2 = new int [20];
  34.  
  35. for (int k=0; k<20; k++)
  36. {tab2[k] = b; }
  37. int max = tab2[0];
  38. for (int j = 0; j < 20; j++)
  39. {
  40. if (tab2[i] > max)
  41. {
  42. max = tab2[i];
  43. }
  44.  
  45.  
  46.  
  47.  
  48. }
  49. {
  50. Debug.Log("największy kwadrat to" + max);
  51. }
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement