• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

wchenfeng

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 32 下一页

2022年4月12日

编写一个函数,在主函数从键盘输入一个大于1的正整数,调用该函数判断是否是素数。

摘要: #include #include int is_prime(int n){ int a,b,k; k=sqrt (n); for(a=1;a<=k;a++) { if(n%a==0) { b=0; break ; } } return b... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(399) 评论(0) 推荐(0)

编写一个程序实现输入垫圈的外直径和垫圈中心空洞的直径,求圆形垫圈的平面面积并输出。要求用浮点数,输出保留小数点后两位。

摘要: #includeint main(){ double r1,r2,s; double a_r1,a_r2; scanf("%lf",&r1); scanf("%lf",&r2); s=3.1415926*(r1*r1-r2*r2); printf("a... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(122) 评论(0) 推荐(0)

编写一个程序实现输入一个十进制整数,将其转化十六进制数输出。

摘要: #includeint main(){ double a,b,c,sum; scanf("%lf%lf%lf",&a,&b,&c); sum=a+b+c; printf("%+020.4f\n",sum/3); return 0;} ... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(290) 评论(0) 推荐(0)

(2)有一函数: 当x<1时,y=x 当1<=x<10时,y=2x-1 当x>=10时,y=3x-11 编写程序输入x,输出y的值.不同分支中使用独立的return,共三个

摘要: #includeint func(int a){ if(a=10) return 3*a-11; else return 2*a-1;}int main(void){ int x; scanf("%d", &x); printf("%d\n... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(291) 评论(0) 推荐(0)

p268 4 宏的使用例子

摘要: #include#define ADD(x) x+xint main(){ int m=1,n=2,k=3; int sum=ADD(m+n)*k; printf("%d",sum);}//10 #include#define ADD(x) x+xint ma... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(52) 评论(0) 推荐(0)

根据年月日,判断已经多少天(3)

摘要: #includeint main(void){int year,month,days=0,day,flag,sum=0;int i=1;scanf("%d",&year);scanf("%d",&month);scanf("%d",&day);if(year%... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(53) 评论(0) 推荐(0)

(第2种)编写一个程序,其有宏定义FUN(x),可用于计算x*2+x*2+x*2,实现从键盘输入一个实数a,输出FUN(a),FUN(a+1),FUN(a)*2的值。

摘要: #include#define FUN(x) x*2+x*2+x*2 //补充宏定义内容void main(void){ int a; scanf("%d", &a); printf("%d\n", FUN(a)); printf("... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(50) 评论(0) 推荐(0)

编写一个结构体数组查找函数find,若找到则输出该结构体变量,否则输出未找到。

摘要: #include #include typedef struct { int num; char name[20]; int score;} stu;int find(stu list[], int list_len, char *find_... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(60) 评论(0) 推荐(0)

(2种)编写一个函数funchar(char *a,char *b,char *c)实现如下功能:将在第一个字符串中出现的但在第二个字符串未出现的字符放在第三个字符串中,函数返回第三个字符串的长度。

摘要: #include#includetypedef struct zimu{ char a[32]; char b[32]; char c[32];}str;int main(){ int i,k=0,j,t=0; str x={0}; scanf("%s",&x... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(69) 评论(0) 推荐(0)

编写一个程序,其有宏定义FUN(x),可用于计算x*2+x*2+x*2,实现从键盘输入一个实数a,输出FUN(a),FUN(a+1),FUN(a)*2的值。

摘要: #include#define FUN(x) x*2+x*2+x*2int main(){ int a,b,c; scanf("%d",&a); b=a+1;c=FUN(a); printf("%d\n",FUN(a)); printf("%d\n",FUN(... 阅读全文

posted @ 2022-04-12 20:03 王陈锋 阅读(48) 评论(0) 推荐(0)

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 32 下一页
 
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3