当前位置:网站首页>学习C语言第二天
学习C语言第二天
2022-07-17 05:04:00 【ruin987】
判断
#include <stdio.h>
int main()
{
printf("%d\n", 5 == 3);
printf("%d\n", 5 > 3);
printf("%d\n", 5 <= 3);
return 0;
//后面到结束的所有东西计算机都不会理睬,//后面是给人注释看的
/**/是在斜杠中间的是注释
多行注释由一对字符序列" / * "开始,而以” * / “结束。
嵌套式IF函数
if(gameover==0){
if(player2move==2)
printf("Your turn\n");
}else
printf("GAME OVER\n");
要在IF和else后面加大括号
Switch-case
int type;
scanf("%d", &type);
switch (type) {
case 1:
printf("你好");
break;
case 2:
printf("早上好");
break;
case 3:
printf("晚上好");
break;
case 4:
printf("再见");
break;
default:
printf("啊,什么啊?");
}
break:是跳出到输出(只能跳出所在的循环)
continue:跳过循环这一轮剩下的语句进入下一轮(只能跳出所在的循环)
数位数的算法
1.用户输入x;
2.初始化 n 为0;
3.x = x / 10,去掉个位;
4.n++;
5.如果x>0,回到3;
否则 n 就是结果
int x;
int n = 0;
scanf("%d", &x);
n++;
x = 10;
while (x > 0) {
n++;
x = 10;
}
printf("%d\n", n);
DO-while
do
{
<循环体语句>
}while(<循环语句>);
IF是一次性的;
while是反复不断的;
#include<stdio.h>
const int MINOR = 35;
int age = 0;
printf("请输入你的年龄:");
scanf("%d", &age);
printf("你的年龄是%d岁。\n,age");
if (age < MINOR) {
printf("年轻是美好的,");
}
printf("年龄决定了你的精神世界,好好珍惜把。\n");
goto<名>
名:
goto:直接跳至名的所属位置
边栏推荐
- PyGame installation -requirement already satisfied
- ModelArts第二次培訓筆記
- 泰迪杯A题完整版 优化更新(4/23)
- Chat about global filter
- CVE-2022-23131 Zabbix SAML SSO认证绕过漏洞
- The code of yolov5 model for pest identification in Title A of the 10th Teddy cup data mining challenge (has been run through, original works, continuously updated)
- elment-ui使用方法
- DSL查询文档
- ModerlArts第一次培训笔记
- 02_電影推薦(ContentBased)_用戶畫像
猜你喜欢

CVE-2019-14234 Django JSONField SQL注入漏洞

Harmonyos third training notes

elment-ui使用方法

Topicexchange switch is simple to use.

Simply and quickly establish a pytorch environment yolov5 target detection model to run (super simple)

MySQL fuzzy matching 1, 11111 similar string problems

【Batch】批量删除中间文件夹-个人研究脚本

ModelArts第二次培訓筆記

读论文《Learning to Measure Changes: Fully Convolutional Siamese Metric Networks for Scene Change Detec》
[email protected] : `node install. Problems of js`"/>solve [email protected] : `node install. Problems of js`
随机推荐
畢設:基於Vue+Socket+Redis的分布式高並發防疫健康管理系統
CVE-2022-23131 Zabbix SAML SSO认证绕过漏洞
事务的使用-django、 SQL工具
Harmonyos fourth training notes
一文了解Zipkin
卷积神经网络
Conception finale: système distribué de gestion de la santé pour la prévention des épidémies hautement simultanées basé sur vue + socket + redis
图片上传的逻辑
3. Restclient query document
Word2Vec原理及应用与文章相似度(推荐系统方法)
[2022 10th Teddy Cup Challenge] Title A: complete version of pest identification (general idea. Detailed process and code and results CSV in compressed package)
天道酬勤,保持热爱
elment-ui使用方法
Add SSL certificate for load balancing
简单快速建立pytorch环境YOLOv5目标检测 模型跑起来(超简单)
First training notes of moderlarts
Order system of middle office
02_ Movie recommendation (contentbased)_ User portrait
Attendance check-in and leave system based on SSM framework
一个问题的探讨