剑指ACM
yang_chengfeng
这个作者很懒,什么都没留下…
展开
-
习题 1-5 打折
#include<stdio.h>int main() { int count; double sum; scanf("%d", &count); sum = count * 95; if(sum>=300){ printf("¥%.2f\n", sum*0.85); } else{ printf("¥%.2f\原创 2015-10-28 20:44:30 · 823 阅读 · 0 评论 -
习题2-4 子序列的和
输入两个正整数n#include<stdio.h>int main() { int n, m, time=0; while(scanf("%d%d", &n, &m)!=EOF){ int i = n; double sum = 0.0; if(n==0 && m==0){ break; } el原创 2016-03-28 01:42:55 · 922 阅读 · 0 评论 -
习题2-3:倒三角
打印一个倒三角形#include<stdio.h>int main() { int n; scanf("%d", &n); int i, j; for(i=1; i<=n; i++){ for(j=1; j<=2*n-1; j++){ if(j<=2*n-i && j>=i){ printf("#原创 2016-03-28 01:12:11 · 386 阅读 · 0 评论 -
第一章 问题
int型最小值和最大值 #include<stdio.h> #include<limits.h>int main() { printf("min = %d\n", INT_MIN); printf("max = %d\n", INT_MAX); return 0; } double型最小值和最大值 #include<stdio.h> #include<float.h>in原创 2015-10-28 21:24:02 · 304 阅读 · 0 评论 -
[UVa 1225]:Digit Counting
Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 < N < 10000) . After that, he counts the number of原创 2016-04-01 13:48:07 · 342 阅读 · 0 评论 -
[UVa 1585]:得分
Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case starts with a line containing a strin原创 2016-04-01 00:21:38 · 402 阅读 · 0 评论 -
习题 1-2 温度
#include<stdio.h>int main() { double f, c; scanf("%lf", &f); c = 5.0*(f-32)/9; printf("%.3f\n", c); return 0; }注意将(提示内容做一定变换):c=5(f-32)/9原创 2015-10-28 20:33:18 · 390 阅读 · 0 评论 -
习题 1-7 是否是闰年?
关于闰年,更详细的看看下面: http://baike.baidu.com/link?url=JnQYNvikYZYb5izKtCDy5AQMOXXWaj1Y7exCun_0_0Euyhu9Kvcx491cYXOoLufF6wwlQQUge7QoP7kXDOZYkolbP-tKxeS-xIuHYpfra7m 1950-2050年间的闰年: 1952,1956,1960,1964,1968原创 2015-10-28 20:58:12 · 489 阅读 · 0 评论 -
1-6 是否能组成三角形?
#include<stdio.h> #include<math.h>int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); if(a+b>c && a+c>b && b+c>a && a>0 && b>0 && c>0){ if(pow(a,2)+pow(b,2)==pow(c,3) || pow(a,2)原创 2015-10-28 20:46:17 · 487 阅读 · 0 评论 -
1-4 正弦和余弦
#include<stdio.h> #include<math.h>int main() { int n; const double PI = acosf(-1); while(scanf("%d", &n)!=EOF){ double k = n/180.0*PI; if(n>=0 && n<360){ printf(原创 2015-10-28 20:42:19 · 360 阅读 · 0 评论 -
习题 2-2:韩信点兵
将题目大概表述为: 韩信点兵,第一次让所有士兵以3人为一组,最后剩下a人,重新排队,以5个人为一队,剩下b个人,第三次以7人为一对,剩下c人,每次都是剩下的人已经不能组成完整一队了(即:a<3,b<5,c<7) #include<stdio.h>int main() { int num, a, b, c, i=1; char m, n; while(scanf("%d%原创 2015-10-28 13:59:02 · 1309 阅读 · 0 评论 -
习题1-3 连续和(1+2+3+······+n)
#include<stdio.h>int main() { int n, sum; scanf("%d", &n); if(n%2==0){ sum = n/2*(1+n); } else{ sum = (1+n)/2*n; } printf("%d\n", sum); return 0; } 注意奇原创 2015-10-28 20:35:57 · 368 阅读 · 0 评论 -
习题 1-1:平均数
输入3个整数,输出它们的平均值,保留三位小数 #include<stdio.h>int main() { int a, b, c; double average; scanf("%d%d%d", &a, &b, &c); average = (a + b + c)/3.0; printf("%f", average); return 0; }原创 2015-10-28 19:18:03 · 466 阅读 · 0 评论 -
水仙花数
水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身。(例如:1^3 + 5^3+ 3^3 = 153) #include<stdio.h> #include<math.h>int main() { int num; for(num=100; num <= 999; num++){ int a, b, c, sum;原创 2015-10-28 14:15:16 · 404 阅读 · 0 评论 -
习题2-5 分数化小数(精确到小数点后c位)
输入a, b, c,输出a/b,精确到小数点后c位,a#include<stdio.h> #define MAX 110int main(void) { int a, b, c; scanf("%d %d %d",&a,&b,&c); int integer = a/b; int remainderTemp=a%b; int arr[MAX]; for(i原创 2016-03-28 02:03:21 · 1852 阅读 · 1 评论