C语言-[编程题入门试炼]【精】-持续更新中。。。

  • 要将"China"译成密码,译码规律是:用原来字母后面的第4个字母代替原来的字母.

例如,字母"A"后面第4个字母是"E"."E"代替"A"。因此,"China"应译为"Glmre"。

请编一程序,用赋初值的方法使cl、c2、c3、c4、c5五个变量的值分别为,’C’、’h’、’i’、’n’、’a’,经过运算,使c1、c2、c3、c4、c5分别变为’G’、’l’、’m’、’r’、’e’,并输出。

 

#include<stdio.h>
int main()
{	
	char c1,c2,c3,c4,c5; 

	scanf("%c%c%c%c%c",&c1,&c2,&c3,&c4,&c5);
	int d1,d2,d3,d4,d5;
	d1 =(int) (c1)+4;
	d2 =(int) (c2)+4;
	d3 = (int) (c3)+4;
	d4 = (int) (c4)+4;
	d5 =(int) (c5)+4;
	printf("%c%c%c%c%c\n",d1,d2,d3,d4,d5);
	return 0;
}

nothing

 

 

 

  • 输入一个华氏温度,要求输出摄氏温度。公式为 c=5(F-32)/9,取位2小数。
#include<stdio.h>
int main()
{	
    float a,b;
    scanf("%f",&a);
    b=5.0*(a-32.0)/9.0f;
    printf("c=%.2f\n",b);
    return 0;
}
nothing
本篇博客,如果你有更好思路欢迎评论!

 

  • 求圆的面积
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{	
    double r,s;
 
    // 用户输入两个浮点数
    scanf("%lf", &r);  
 
    // 两个浮点数相乘
    s = r * r*PI;  
 
    // 输出结果, %.2lf 保留两个小数点
    printf("%.2lf\n", s);
    
    return 0;
}

nothing

 

#include<stdio.h>
int main()
{	//三个数找最大值
	int a,b,c,max;
 
    scanf("%d %d %d", &a,&b,&c);  
	if(a<c && b<c){
		max=c;
	}else if(a<b && b>c){
		max=b;
	}else if(a>b&&a>c){
		max=a;
	}

	printf("%d\n", max);
	
    return 0;
}

 

#include<stdio.h>
int main()
{	//分段函数求值
	int x,y;
 
    scanf("%d", &x);  
	if(x<1){
		y=x;
	}else if(x>1&&x<10){
		y=2*x-1;
	}else if(x>=10){
		y=x*3-11;
	}

	printf("%d\n", y);
	
    
    
    return 0;
}

 

#include<stdio.h>
int main()
{	//成绩评定
	int x;
	char y;
    scanf("%d", &x);  
	if(x<60){
		y='E';
	}else if(x>=60&&x<69){
		y='D';
	}else if(x>=70&&x<79){
		y='C';
	}else if(x>=80&&x<89){
		y='B';
	}else if(x>=90&&x<101){
		y='A';
	}

	printf("%c\n", y);
	
    return 0;
}

最新的请移步: 传送门,欢迎star!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值