- 博客(13)
- 收藏
- 关注
原创 [PTA]7-10 计算工资 (15 分)
先判断工龄,再判断工时,嵌套条件。#include<stdio.h>int main(){ int year; int time; float salary = 0; scanf("%d %d",&year,&time); if( year < 5){ if(time > 40){ salary = (time - 40) *45...
2019-01-01 01:15:00
2305
原创 [PTA]7-9 用天平找小球 (10 分)
#include<stdio.h>int main(){ int a, b, c; scanf("%d %d %d",&a,&b,&c); if(a != b && a != c){ printf("A"); }else if(a == c){ printf("B"); }else{ printf("C&
2019-01-01 01:12:38
875
原创 [PTA]7-8 超速判断 (10 分)
同样的简单条件语句,注意输出格式。#include<stdio.h>int main(){ int speed ; scanf("%d",&speed); if(speed > 60){ printf("Speed: %d - Speeding",speed); }else{ printf("Speed: %d - OK",speed); } ...
2019-01-01 01:11:15
1451
原创 [PTA]7-7 12-24小时制 (15 分)
if语句控制三个输出。#include <stdio.h>int main(){ int hour,minute; scanf("%d:%d",&hour,&minute); if(hour > 12){ printf("%d:%d PM",hour-12,minute); }else if(hour == 12){ printf("%d:...
2019-01-01 01:10:05
1875
原创 [PTA]7-6 混合类型数据格式化输入 (5 分)
#include <stdio.h>int main(){ float f1,f2; int i; char c; scanf("%f %d %c %f",&f1,&i,&c,&f2); printf("%c %d %.2f %.2f",c,i,f1,f2); return 0;}
2019-01-01 01:08:52
1782
1
原创 [PTA]7-5 表格输出 (5 分)
照抄即可。#include<stdio.h>#include<math.h>int main(){ printf("------------------------------------\n"); printf("Province Area(km2) Pop.(10K)\n"); printf("-----------------------...
2019-01-01 01:07:41
888
原创 [PTA]7-4 BCD解密 (10 分)
#include <stdio.h>int main (){ int n; scanf("%d",&n); printf("%d",n / 16 * 10 + n % 16); return 0;}
2019-01-01 01:06:31
550
原创 [PTA]7-3 逆序的三位数 (10 分)
既然是三位数,分别将三个位置求出在反向相加即可。#include<stdio.h>int main(){ int n; scanf("%d",&n); printf("%d",(n % 10) * 100+((n % 100) / 10) * 10+(n / 100)); return 0;}...
2019-01-01 01:04:42
1342
原创 [PTA]7-2 然后是几点 (15 分)
将起始、流逝的时间化成分钟,加起来,在分别同60取余、作除法即可。(题目保证起始结束的时间在一天之内)#include <stdio.h>int main (){ int ts,tp; scanf("%d %d",&ts,&tp); printf("%d",(ts / 100 * 60 + ts % 100 + tp) / 60 * 100 + (ts /...
2019-01-01 01:00:37
1702
原创 [PTA]7-1 厘米换算英尺英寸 (15 分)
比较简单的一道题,照公式求出总英寸数,再分别与12作除、取余即可。此题英寸与英尺均是整形。#include &lt;stdio.h&gt;int main()//metre=(foot+inch/12)*0.3048{ int centimeter,totalinch; scanf("%d",&amp;centimeter); totalinch = centimeter/30.48...
2019-01-01 00:56:56
2080
原创 [PTA]7-38 数列求和-加强版 (20 分)
基本思路:1.因为0≤N≤1000000\leq N\leq 1000000≤N≤100000,因此最大数可以达到101010万位,因此考虑用数组解决问题;2.构造一个新的数组用来存储数列和的每一位,简单观察可知数列求和有如下规律:第iii位是N−iN-iN−i个AAA相加,因此个位是NA10\frac{NA}{10}10NA的余数,NA10\frac{NA}{10}10NA的值进位。3...
2018-12-31 14:34:01
4175
2
原创 [PTA]6-12 判断奇偶性 (10 分)
这道题很简单,奇偶判别函数只需要输出1,0。思路是直接让N除2取余,返回此值的非即可。(奇数除2余1取非为0,偶数除2余0取非为1。)#include &lt;stdio.h&gt;int even( int n );int main(){ int n; scanf("%d", &amp;n); if (even(n)) printf..
2018-12-31 12:04:36
3211
原创 [PTA]7-22 龟兔赛跑(20分)
[PTA]7-22 龟兔赛跑(20分)C语言的龟兔赛跑问题,用的办法比较笨,逻辑应该还算清晰。#include <stdio.h>int main(){ int RabbitDistance,T,time=0;//time在这里计数,以10位单位,每10分钟检查一次龟兔的距离。 scanf("%d",&T); if(T <= 10){ printf("...
2018-12-30 16:55:31
2064
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人