摘要: 1、定义圆的半径,求面积。 package a; public class A { public static void main(String[] args) { double r=10.0; System.out.println("半径为10的圆的面积为:"+(r*r*3.14)); } } 2 阅读全文
posted @ 2023-03-19 10:56 荽邊 阅读(35) 评论(0) 推荐(0)
摘要: 1.实现一个菜单 可以切换 ,可以返回主菜单 主菜单 1.登录 2.注册 3.输出水仙花数 4.退出程序 请选择: 选择后实现对应的功能 #include<stdio.h> #include<string.h> void denglu(); void zhuce(); void shuixianhu 阅读全文
posted @ 2021-11-30 16:14 荽邊 阅读(16) 评论(0) 推荐(0)
摘要: 1编写程序,使用循环结构,计算字符串长度。 #include<stdio.h> main(){ char a[50]; int i; gets(a); for(i=0;a[i]!='\0';i++); printf("%d",i); } 2编写程序,统计大写字母。 #include<stdio.h> 阅读全文
posted @ 2021-11-23 09:47 荽邊 阅读(19) 评论(0) 推荐(0)
摘要: 1.定义一个含有8个存储单元的实型数组,从键盘上接收,然后逆序输出. #include<stdio.h> main(){ double a[8]; int i,j; for(i=0;i<=7;i++){ scanf("%lf",&a[i]); } for(j=7;j>=0;j--){ printf( 阅读全文
posted @ 2021-11-16 15:50 荽邊 阅读(30) 评论(0) 推荐(0)
摘要: 1.编写程序,求s=1+(1+2)+(1+2+3)...(1+2+3....+n) #include<stdio.h> main(){ int a,b,n,i,j; scanf("%d",&n); a=0; b=0; for(i=1;i<=n;i++){ b+=i; a=a+b; } printf( 阅读全文
posted @ 2021-11-13 17:05 荽邊 阅读(20) 评论(0) 推荐(0)
摘要: #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(){ int i,j,v; for( 阅读全文
posted @ 2021-11-09 10:18 荽邊 阅读(10) 评论(0) 推荐(0)
摘要: 1 使用while语句求和sum=1+3+5+7+...+21 #include<stdio.h> main(){ int sum,i; sum=0; i=1; while(i<=21){ sum+=i; i+=2; } printf("%d",sum); } 2 编写使用while语句求和sum= 阅读全文
posted @ 2021-11-04 15:25 荽邊 阅读(21) 评论(0) 推荐(0)
摘要: 1.判断n是正数还是负数 #include<stdio.h> main(){ float n; printf("请输入一个数\n"); scanf("%f",&n); if(n<0){ printf("%f为负数",n); }else if(n>0){ printf("%f为正数",n); }els 阅读全文
posted @ 2021-11-04 15:11 荽邊 阅读(10) 评论(0) 推荐(0)
摘要: 1输入成绩进行分级 #include<stdio.h> main(){ int mark; printf("请输入学生成绩(0-100)"); scanf("%d",&mark); switch(mark/10){ case 10: case 9:printf("A\n");break; case 阅读全文
posted @ 2021-10-26 15:31 荽邊 阅读(22) 评论(0) 推荐(0)
摘要: 1编写程序,判断一个数n是正数还是负数 #include<stdio.h> main(){ int n=2; if(n<0){ printf("n是负数"); }else{ printf("n是正数"); } } 2编写程序,计算出租车行驶距离与费用之间的关系.起步3km内,8元;之后1.6元/km 阅读全文
posted @ 2021-10-21 20:28 荽邊 阅读(18) 评论(0) 推荐(0)