import React, { useState, useEffect } from "react"; import { View, Text, StyleSheet,…
- User
import React, { useState, useEffect } from "react"; import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
const SymmetricGridScreen = () => { const [grid, setGrid] = useState([]);
const generateSymmetricGrid = () => { const newGrid = Array(5) .fill() .map(() => Array(5).fill(0));
for (let i = 0; i < 5; i++) { for (let j = i; j < 5; j++) { const randomNum = Math.floor(Math.random() * 10); newGrid[i][j] = randomNum; if (i !== j) { newGrid[j][i] = randomNum; } } } setGrid(newGrid);};
useEffect(() => { generateSymmetricGrid(); }, []);
return ( Simetrik Grid {grid.map((row, rowIndex) => ( {row.map((cell, cellIndex) => ( {cell} ))} ))} Yeni Grid Oluştur ); };
const styles = StyleSheet.create({ container: { flex: 1, alignItems: "center", justifyContent: "center", backgroundColor: "#f0f0f0", }, title: { fontSize: 24, fontWeight: "bold", marginBottom: 20, }, gridContainer: { borderWidth: 1, borderColor: "#000", }, row: { flexDirection: "row", }, cell: { width: 40, height: 40, borderWidth: 1, borderColor: "#000", alignItems: "center", justifyContent: "center", }, cellText: { fontSize: 18, }, button: { marginTop: 20, backgroundColor: "#007AFF", padding: 10, borderRadius: 5, }, buttonText: { color: "#fff", fontSize: 16, }, });
export default SymmetricGridScreen;
- Assistant