摘要: 1.定义圆形半径,求面积 package shg; import java.util.Scanner; public class Test { public static void main(String[] args) {// TODO Auto-generated method stubScan 阅读全文
posted @ 2023-03-22 15:17 刘凯铭 阅读(25) 评论(0) 推荐(0)
摘要: 1.输入一个三位数,求个位,十位,百位 #include<stdio.h> main() { int a=857; int ge=a%10; int shi=a/10%10; int bai=a/100; printf("个位是%d,十位是%d,百位是%d",ge,shi,bai); } 2.输入一 阅读全文
posted @ 2021-12-04 14:56 刘凯铭 阅读(41) 评论(0) 推荐(0)
摘要: 1.实现一个菜单 可以切换 ,可以返回主菜单 主菜单 1.登录 2.注册 3.输出水仙花数 4.退出程序 请选择: 选择后实现对应的功能 #include<stdio.h> #include<string.h> void mainMenu(); void login(); void regist() 阅读全文
posted @ 2021-12-04 14:51 刘凯铭 阅读(21) 评论(0) 推荐(0)
摘要: 1.定义一个含有8个存储单元的实型数组,从键盘上接收数,然后逆序输出 #include<stdio.h> main(){ double a[8]; int i; for(i=0;i<=7;i++); scanf("%lf",&a[i]); for(i=7;i>=0;i--); printf("%f" 阅读全文
posted @ 2021-11-23 21:24 刘凯铭 阅读(39) 评论(0) 推荐(0)
摘要: 1.编写程序,统计字符串中大写字母的个数 #include<stdio.h> main() { char str[5]; int i,cnt; cnt=i=0; gets(str); while(str[i]!='\0') {if(str[i]>='A'&&str[i]<='Z') cnt++; i 阅读全文
posted @ 2021-11-23 21:24 刘凯铭 阅读(33) 评论(0) 推荐(0)
摘要: 1. 猜数字:随机产生一个0-99的数,猜猜看如果大了就提示大了点如果小了就提示小了点直到猜对为止 #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int a,n; srand((unsigned)time( 阅读全文
posted @ 2021-11-23 21:23 刘凯铭 阅读(25) 评论(0) 推荐(0)
摘要: 1.输出图形 #include <stdio.h> main() { int i,j; for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } } 2..输出图形 #include <stdio.h> main() 阅读全文
posted @ 2021-11-23 21:22 刘凯铭 阅读(25) 评论(0) 推荐(0)
摘要: 1.编写程序,使用while语句求和sum=1+3+5+…+21 #include<stdio.h> main() { int i=1,sum=0; while(i<=21){ sum+=i; i+=2; } printf("Sum=%d\n",sum); } 2.编写程序,使用while语句求和s 阅读全文
posted @ 2021-11-23 21:17 刘凯铭 阅读(17) 评论(0) 推荐(0)
摘要: 1. 分数转成等级 switch #include<stdio.h> main() { int mark; printf("请输入学生的分数(0-100):\n"); scanf("%d",&mark); switch(mark/10) { case 10: //与case9;共用同一条语句 cas 阅读全文
posted @ 2021-10-30 21:15 刘凯铭 阅读(26) 评论(0) 推荐(0)
摘要: 1.编写程序,判断一个数n是正数还是负数 编写程序,判断一个数n是正数还是负数 #include<stdio.h> main() { float n; scanf("%f",&n); if(n>0) printf("正数!\n"); else if(n==0) printf("0既不是正数,也不是负 阅读全文
posted @ 2021-10-22 20:18 刘凯铭 阅读(50) 评论(0) 推荐(0)