【C语言】基础篇

ops/2024/10/19 1:51:27/
  • 简单输出“helloword”

#include<stdio.h>
int main(){printf("hello world!");return 0;
}
  •  和与商

#include<stdio.h>
int main(){int a,b,sum,quotient;printf("Enter two numbers:");scanf("%d %d",&a,&b);sum = a + b;quotient = a / b;printf("%d + %d = %d\n",a,b,sum);if(b != 0){printf("%d / %d = %d",a,b,quotient);}else{printf("请检查你输入的数字是否正确。");}return 0;
}
  • 判断奇偶

#include<stdio.h>
int main(){int number;printf("Enter a number:");scanf("%d",&number);if(number%2 == 0){printf("%d is even",number);}else{printf("%d is odd",number);}return 0;
}
  • 判断闰年

#include<stdio.h>
int main(){int year;printf("Enter a year:");scanf("%d",&year);if(year % 4 == 0 & year % 100 != 0 | year % 400 == 0){printf("%d is a leap year",year);}else{printf("%d is not a leap year",year);}
}
  • 求阶乘

#include<stdio.h>
int main(){int n,i;int t = 1;printf("Enter a number:");scanf("%d",&n);for(i = 1;i <= n;i++){t = t * i;}printf("factorial = %d",t);return 0;
}


http://www.ppmy.cn/ops/122065.html

相关文章

sentinel原理源码分析系列(一)-总述

背景 微服务是目前java主流开发架构&#xff0c;微服务架构技术栈有&#xff0c;服务注册中心&#xff0c;网关&#xff0c;熔断限流&#xff0c;服务同学&#xff0c;配置中心等组件&#xff0c;其中&#xff0c;熔断限流主要3个功能特性&#xff0c;限流&#xff0c;熔断&…

安卓WPS Office v18.13.0高级版

软件介绍 WPS Office&#xff0c;金山WPS移动版&#xff0c;使用人数最多的移动办公软件套件。独有手机阅读模式&#xff0c;字体清晰翻页流畅&#xff1b;完美支持文字&#xff0c;表格&#xff0c;演示&#xff0c;PDF等51种文档格式&#xff1b;新版本具有海量精美模版及高…

安装配置pytorch(cuda、、cudnn、torch、torchvision对应版本)

参考&#xff1a; Pytorch环境配置——cuda、、cudnn、torch、torchvision对应版本&#xff08;最全&#xff09;及安装方法_cuda12.2对应的pytorch版本-CSDN博客 https://download.pytorch.org/whl/torch_stable.html Previous PyTorch Versions | PyTorch

探索AI写作助手软件的神奇功能

无论是撰写文章、报告、文案&#xff0c;还是创作故事、诗歌等&#xff0c;我们都希望能够更加高效、准确地表达自己的想法。自己喜欢的文章创作可以自由自在&#xff0c;但是很多公文或者论文都有一定的格式要求&#xff0c;我们可以借助一些ai写作助手来完成这项工作哦。 1.…

国内旅游:现状与未来趋势分析

在当今社会快速发展的背景下&#xff0c;国内旅游更是呈现出蓬勃的发展态势。中国&#xff0c;这片拥有悠久历史、灿烂文化和壮丽山河的广袤土地&#xff0c;为国内旅游的兴起与发展提供了得天独厚的条件。 本报告将借助 DataEase 强大的数据可视化分析能力&#xff0c;深入剖…

(done) Go 语言:三种多文件协作方式

go 语言多文件协作有三种方式&#xff1a; 1.同一文件夹下&#xff0c;同时编译运行多个 go 文件 2.使用 go.mod 配置项目结构&#xff0c;把不同文件分在不同包里 3.把一部分文件编译成动态库 .so 文件&#xff0c;然后一个 main 程序加载调用他们 task1: 同一文件夹下&#x…

uniapp设置从右上角到左下角的三种渐变颜色

推荐学习文档 golang应用级os框架&#xff0c;欢迎stargolang应用级os框架使用案例&#xff0c;欢迎star案例&#xff1a;基于golang开发的一款超有个性的旅游计划app经历golang实战大纲golang优秀开发常用开源库汇总想学习更多golang知识&#xff0c;这里有免费的golang学习笔…

vAPI靶场

前言 自行去搭建vAPI靶场&#xff0c;配合postman使用 vapi1 创建用户 第一个用户 {"username": "shi","name": "shi1","course": "nihao","id": 10 } 第二个用户 {"username": "hui…