摘要: 1、定义圆的半径,求面积。 1 public class Main { 2 public static void main(String[] args) { 3 double r=5; 4 System.out.println("圆的面积为"+3.14*r*r); 5 } 6 } 2、华氏温度和摄氏 阅读全文
posted @ 2023-03-19 14:27 coldlane 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 1.实现一个菜单 可以切换 ,可以返回主菜单 主菜单 1.登录 2.注册 3.输出水仙花数 4.退出程序 请选择: 选择后实现对应的功能 #include<stdio.h> #include <string.h> void login(); void mainMenu(); void rigist( 阅读全文
posted @ 2021-12-04 15:58 coldlane 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 1求字符串长度 #include <stdio.h> main() { char str[80]; int i=0; int length=0; gets(str); puts(str); while(str[i++]!='\0') length++; printf("字符串长度为:%d\n",le 阅读全文
posted @ 2021-11-23 09:40 coldlane 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 1.随机产生一个0-99的数,猜猜看,如果大了,就显示大了点;如果小了,就显示小了点,直到猜对为止。 #include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int a,n; srand((unsigned)time(NU 阅读全文
posted @ 2021-11-20 17:43 coldlane 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 1 定义一个含有八个存储单元的实型数据,从键盘上接收数,然后逆行输出。 #include<stdio.h> main() { int number[8]; int i; for(i=1;i<8;i++){ scanf("%d",&number[i]); } for(i=7;i>=1;i--){ pr 阅读全文
posted @ 2021-11-20 17:36 coldlane 阅读(1) 评论(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语句求和 阅读全文
posted @ 2021-11-20 17:16 coldlane 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,判断一个数n是正数还是负数。 #include<stdio.h> main() { float n; scanf("%f",&n); if(n>0) printf("正数!\n"); else if(n==0) printf("0既不是正数,也不是负数!\n"); else print 阅读全文
posted @ 2021-11-20 16:59 coldlane 阅读(7) 评论(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("%d\n",sum) 2.编写程序,使用while语句求和sum=1+1/3 阅读全文
posted @ 2021-11-08 21:12 coldlane 阅读(9) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>main(){ int n; printf("请输入一个数:\n"); scanf("%d",&n); if(n>0) printf("%d是正数!\n",n); else if(n==0) printf("%d既不是正数,也不是负数\n",n); else pri 阅读全文
posted @ 2021-11-08 21:02 coldlane 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 1. 使用switch-case语句编写代码。#include<stdio.h>main(){ int mark; printf("输入学生成绩(0-100):\n"); scanf("%d",&mark); switch(mark/10){ case 10: case 9:printf("A\n" 阅读全文
posted @ 2021-11-08 20:53 coldlane 阅读(12) 评论(0) 推荐(0) 编辑