c入门基础题(1)

5 篇文章 0 订阅

1、鹦鹉学舌1——C语言初学者百题大战之三

#include <stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    printf("%d",a);
    return 0;
}

2、a + b ——C语言初学者百题大战之四

#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    printf("a=""%d\n",a);
    printf("b=""%d\n",b);
    printf("s=""%d\n",a+b);
    return 0;
}

3、a - b ——C语言初学者百题大战之五

#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    printf("a=""%d\n",a);
    printf("b=""%d\n",b);
    printf("s=""%d\n",a-b);
    return 0;
}

4、零起点学算法05——除法算术题

#include <stdio.h>
int main(){
	printf("%d\n",12/2);
	return 0;
}

5、零起点学算法08——简单的输入和计算(a+b)

#include <stdio.h>
int main()
{
    int a;
    int b;
    scanf("%d %d",&a,&b);
    printf("%d",a+b);
    return 0;
}
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    printf("%d",a+b);
    return 0;
}

6、零起点学算法09——继续练习简单的输入和计算(a-b)

#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    c=a-b;
    printf("%d\n",c);
}

7、零起点学算法10——求圆柱体的表面积

多组测试数据,每组输入底面半径r和高h
输入
3.5 9
输出
Area=274.889

#include <stdio.h>
#include <math.h>
const double pi=4.0 * atan(1.0);
int main()
{
    double r,h,n,i,sum;
    while(scanf("%lf %lf",&r,&h)!=EOF){
        sum=0;
        sum += 2*pi*r*r;
        sum += 2*pi*r*h;
        printf("Area=%.3lf\n",sum);
    }
    return 0;
}

8、零起点学算法11——求梯形面积

输入
多组测试数据,每组输入3个浮点数,分别表示上底、下底和高,中间用逗号隔开(题目包含多组数据)
输出
输出梯形的面积,保留2位小数
样例输入
2,4,5
样例输出
15.00

#include <stdio.h>
int main(){
	double a,b,h,s;
	while(scanf("%lf,%lf,%lf",&a,&b,&h)!=EOF){
		s=(a+b)*h/2;
		printf("%.2lf\n",s);
	}
	return 0;
}

9、零起点学算法02——输出简单的句子

#include<stdio.h>
int main(){
    printf("Nice to meet you!");
    return 0;
}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值