摘要: 1. 定义圆形半径,求面积。int r =5。 public class ljh { public static void main(String[] args) { // TODO Auto-generated method stub int a=3 ,r=5; int s; s=a*r*r; S 阅读全文
posted @ 2023-03-21 13:48 风再起时, 阅读(13) 评论(0) 推荐(0) 编辑
摘要: ⦁ 用循环结构求字符串长度 #include <stdio.h> main() { char str[80]; int i=0; int length=80; gets(str); puts(str); while(str[i++]!='\0') length++; printf("字符串的长度为: 阅读全文
posted @ 2021-11-27 23:27 风再起时, 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 1定义一个含有八个储存单元的实验数组,从键盘上接收数,然后输出。 #include <stdio.h> main() { int i; double a[8]; for(i=0;i<=7;i++) { scanf("%lf",&a[8]); for(i=7;i>=0;i--) printf("%f" 阅读全文
posted @ 2021-11-18 20:56 风再起时, 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 1. #include<stdio.h> main() { int i,j; for(i=1;i<=5;i++) { for(j=1;j<=9-2*i;j++) printf("*"); printf("\n"); } } 2. #include <stdio.h> main(){ int i,j, 阅读全文
posted @ 2021-11-14 10:33 风再起时, 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 编写程序,使用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); } 编写程序,使用while语句求和sum 阅读全文
posted @ 2021-11-05 19:41 风再起时, 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 编写程序判断n是正数还是负数 #include <stdio.h> main(){ int n; scanf("%d",&n); if(n>0){ printf("正数"); } else if(n<0){ printf("负数"); } } 2.使用条件运算符,找出四个数a,b,c,d四个数中最大 阅读全文
posted @ 2021-10-31 14:36 风再起时, 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 教材P52 例4-8 分数转成等级 switch #include <stdio.h> main(){ int mark; printf("输入学生的分数(0-100):\n"); scanf("%d",&mark); switch(mark/10) { case 10:printf("A\n"); 阅读全文
posted @ 2021-10-27 22:09 风再起时, 阅读(9) 评论(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 printf( 阅读全文
posted @ 2021-10-19 10:33 风再起时, 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,定义两个整形变量,赋值并输出 #include <stdio.h> main(){ int a=5,b=8; printf("%d %d\n",a,b); } 2.编写程序,定义一个单精度和一个双精度的变量,赋值并输出。 #include <stdio.h> main(){ float 阅读全文
posted @ 2021-10-12 11:41 风再起时, 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,输出“我爱学习c语言!” #include<stdio.h> main(){ printf("我爱学习c语言!"); } 2.分行输出自己的专业和姓名 #include<stdio.h> main(){ printf("计算机科学与技术\n"); printf("龙建行\n"); } 阅读全文
posted @ 2021-10-01 16:08 风再起时, 阅读(9) 评论(0) 推荐(0) 编辑