正如我在另一个问题中提到的,我一直在用KN King's C Programming:A Modern Approach(2ndEdn)教自己C语言.
我很享受,但是如果合适的话,我希望在这里发出奇怪的问题以获得建议,因为不幸的是我没有导师,有些人会提出更多问题然后他们回答!
我要问一个问题,要求我编写一个程序,找出用户输入的四个整数中最大和最小的...我想出办法找到最大的,但对于我的生活可以弄清楚如何让最小的出局.问题是四个if语句应该足够了.数学不是我的强项,我很感激任何建议!
#include <stdio.h>
int main(int argc, const char *argv[])
{
int one, two, three, four;
printf("Enter four integers: ");
scanf("%d %d %d %d", &one, &two, &three, &four);
if (four > three && four > two && four > one)
printf("Largest: %d", four);
else if (three > four && three > two && three > one)
printf("Largest: %d", three);
else if (two > three && two > four && two > one)
printf("Largest: %d", …Run Code Online (Sandbox Code Playgroud) 我刚开始用KN King's C Programming:A Modern Approach(2ndEdn)教自己C语言.
我很享受,但是如果合适的话,我希望在这里发出奇怪的问题以获得建议,因为不幸的是我没有导师,有些人会提出更多问题然后他们回答!
我正在做一个关于输入整数并以八进制显示它的问题.它说有一种简单的方法可以做到,但这本书后面会有.我想出了以下内容:
// Convert a number to octal
int n, n2, n3, n4, n5, n6;
printf("Enter a number between 0 and 32767: ");
scanf("%d", &n);
n6 = n % 8;
n5 = (n / 8) % 8;
n4 = ((n / 8) / 8) % 8;
n3 = (((n / 8) / 8) / 8) % 8;
n2 = ((((n / 8) / 8) / 8) / 8) % 8;
printf("%d%d%d%d%d", n2, n3, n4, …Run Code Online (Sandbox Code Playgroud) 我从W3Schools网站上学习了几本书中的PHP,并使用了大量的Stack Overflow帖子.
为了尝试将某些内容付诸实践,我正在尝试创建一个实现用户身份验证系统的小型图库.用户具有安全访问权限,可以确定他们已经阅读,读写访问权限或管理其他用户等.我只是登录并添加用户的东西.
我已经模仿了我的工作,每个人都有一个唯一的员工ID和8位数的电子邮件ID.
我知道这是一个很长的镜头,但我只是想知道是否有人能够看一看并告诉我我的代码是否正在走向正确的轨道?从书本中提供的基本例子中将这样的"真实世界"放在一起是如此不同.任何意见和建议将不胜感激....
的login.php
<!DOCTYPE html>
<?php
// Connect to the database
include('./helpers/db.php');
include('./helpers/general.php');
// Check if the user has submitted their details.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$loginId = htmlspecialchars(($_POST['userId']));
$loginPass = htmlspecialchars(sha1($_POST['password']));
// Check if they've submitted blank details.
if (!checkLoginId($loginId) || (!checkPassword($_POST['password']))) {
$errorMsg = "Please enter a valid username or password!";
}
else {
// Select the details we want for the session info.
$stmt = $dbh->prepare("SELECT firstName, lastName, securityLevel FROM
userDetails WHERE registeredNumber …Run Code Online (Sandbox Code Playgroud)