
初学C语言
JC677
这个作者很懒,什么都没留下…
展开
-
判断是否为素数(bool函数应用)
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> bool IsPrime(int val) { int i; //素数判断条件:除1和它本身外再没有其他公因数 for(i =2; i <val; ++i) { if(val%i == 0) break; } if(i == val) return true; else return false; } int main() { //输出0到100之原创 2021-04-17 08:24:57 · 3374 阅读 · 0 评论 -
动态数组构建(malloc函数)
#include <stdio.h> #include <stdlib.h> #include <malloc.h> int main() { int len; int *pArr; int i; printf(“请输入数组长度: “); //用户提醒 scanf(”%d”,&len); pArr = (int *)malloc(len * sizeof(int)); /*原创 2021-04-17 00:28:47 · 807 阅读 · 0 评论 -
结构体简单应用——制作一个简单的学生信息管理系统
#include <stdio.h> #include <stdlib.h> #include <malloc.h> struct student { int age; char name[100]; float score; }; int main() { int n; printf(“请输入学生个数: “); scanf(”%d”, &n); //构造动态数组 struct student * pArr; pArr = (struct student *)ma原创 2021-04-16 00:05:02 · 355 阅读 · 0 评论 -
斐波那契数列
斐波那契数列—循环的简单应用原创 2021-04-15 08:53:19 · 76 阅读 · 0 评论