mirror of
https://github.com/arthur-pbty/nsi.git
synced 2026-06-15 15:56:46 +02:00
update checkerboard project
This commit is contained in:
@@ -1,20 +0,0 @@
|
|||||||
body {
|
|
||||||
background-color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
border-collapse:collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.n {
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.b {
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Damier</title>
|
|
||||||
<link rel="stylesheet" href="damier.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<form method="post" action="damier2.php">
|
|
||||||
<label for="ligne">ligne</label>
|
|
||||||
<input type="text" name="ligne" require>
|
|
||||||
|
|
||||||
<label for="colum">colone</label>
|
|
||||||
<input type="text" name="colum" require>
|
|
||||||
|
|
||||||
<button type="submit">ok</button>
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Damier</title>
|
|
||||||
<link rel="stylesheet" href="damier.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<table>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$ligne = $_POST['ligne'];
|
|
||||||
$colone = $_POST['colum'];
|
|
||||||
$color = 'b';
|
|
||||||
|
|
||||||
for ($i=0; $i<$ligne ; $i++) {
|
|
||||||
echo("<tr>");
|
|
||||||
for ($j=0; $j<$colone ; $j++) {
|
|
||||||
if ($color == 'b') {
|
|
||||||
$color = 'n';
|
|
||||||
} else {
|
|
||||||
$color = 'b';
|
|
||||||
}
|
|
||||||
echo("<td class='$color'></td>");
|
|
||||||
|
|
||||||
}
|
|
||||||
echo("</tr>");
|
|
||||||
if ($i % 2 == 0) {
|
|
||||||
$color = 'n';
|
|
||||||
} else {
|
|
||||||
$color = 'b';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Checkerboard</title>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form method="post">
|
||||||
|
<label for="row">Rows:</label>
|
||||||
|
<input type="number" name="row" required>
|
||||||
|
|
||||||
|
<label for="column">Columns:</label>
|
||||||
|
<input type="number" name="column" required>
|
||||||
|
|
||||||
|
<button type="submit" name="submit">Validate</button>
|
||||||
|
</form>
|
||||||
|
<table>
|
||||||
|
<?php
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
|
||||||
|
$row = $_POST['row'];
|
||||||
|
$column = $_POST['column'];
|
||||||
|
$color = 'b';
|
||||||
|
|
||||||
|
for ($i=0; $i<$row ; $i++) {
|
||||||
|
echo("<tr>");
|
||||||
|
for ($j=0; $j<$column ; $j++) {
|
||||||
|
if ($color == 'b') {
|
||||||
|
$color = 'n';
|
||||||
|
} else {
|
||||||
|
$color = 'b';
|
||||||
|
}
|
||||||
|
echo("<td class='$color'></td>");
|
||||||
|
}
|
||||||
|
echo("</tr>");
|
||||||
|
if ($i % 2 == 0) {
|
||||||
|
$color = 'n';
|
||||||
|
} else {
|
||||||
|
$color = 'b';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form input[type="number"],
|
||||||
|
form button {
|
||||||
|
margin: 5px;
|
||||||
|
padding: 8px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.n {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.b {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user