![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
寒假作业
der跑反了!
这个作者很懒,什么都没留下…
展开
-
2021-08-27
#include <stdio.h>int main(void){int n;double sum;while(n>=0){scanf("%d",&n);if(n==1)sum+=n;if(n%2!= 0)sum+=n;}printf("%.2lf",sum);return 0;}//2.使用函数计算两点间的距离:给定平面任意两点坐标(x1,y1)和(x2,y2),求这两点之间的距离(保留两位小数)。#include <stdio.h>原创 2021-08-27 16:26:41 · 97 阅读 · 0 评论 -
91-----100
91.#include <stdio.h>#define SIZE 10void main(){int x[SIZE],i,n=0;float sum=0;printf(“Enter 10 integers:\n”);for(i=0;i<SIZE;i++){printf("%d:",i+1);scanf("%d",&x[i]);if(x[i]>0){sum+=x[i];n++;}}printf(“the counter is %d\n”,n原创 2021-02-26 14:24:36 · 105 阅读 · 0 评论 -
81-----90
81.#include<stdio.h>int main(){char ch;ch=getchar();if(ch<‘A’||ch>‘Z’){printf(“输入的不是大写字母,请重新输入!\n”);}ch=ch+32;putchar(ch);putchar(’\n’);}82.#include <stdio.h>#include <conio.h>void main (){double a,b,c;char op;p原创 2021-02-26 14:17:59 · 81 阅读 · 0 评论 -
18
18.#include<stdio.h>int main(){float I=0,money01, money02, money03, money04, money05;float bonus=0;money01 = 100000 * 0.1;money02 = money01 + 100000 * 0.075;money03 = money02 + 200000 * 0.05;money04 = money03 + 200000 * 0.03;money05 = money原创 2021-02-26 14:09:33 · 62 阅读 · 0 评论 -
71----80
71.#include"stdio.h"void main(){int i=1;while(i<=10){printf("%d*%d=%d\n",i,i,i*i);i++;}}72.#include"stdio.h"void main(){int sum=0;int num;while(1){scanf("%d",&num);if(num==0)break;elsesum+=num;}printf(“sum=%d\n”,sum);}73.原创 2021-02-26 14:05:21 · 54 阅读 · 0 评论 -
56----------70
56.#include “stdio.h”void main(){int i,j,temp,temp1,temp2;int number;int end;int a[9]={14,20,5,6,7,8,11,12};for(i=0;i<8;i++)for(j=0;j<8-i;j++)if(a[j]<a[j+1]){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}for(i=0;i<8;i++)printf("%5d",a[i])原创 2021-02-26 13:56:06 · 59 阅读 · 0 评论 -
45-----55
45.#include<stdio.h>void main(){int i,j,n=0,a[100][100]={1};printf(“请输入杨辉三角的行数:”);scanf("%d",&n);if(n>=1||n<=99){for(i=1;i<=n;i++){a[i][0]=1; for(j=1;j<i;j++) a[i][j]=a[i-1][j-1]+a[i-1][j]; } f原创 2021-02-24 13:56:49 · 51 阅读 · 0 评论 -
35~~~44
35.#include"stdio.h"#include"math.h"int fun(int n){int i;if(n2)return 1;if(n%20)return 0;for(i=3;i<=sqrt(n);i+=2)if(n%i0)return 0;return 1;}main(){int num,counter=0;for(num=100;num<=200;num++)if(fun(num)){counter++;printf("%d\t"原创 2021-02-23 14:00:23 · 49 阅读 · 0 评论 -
24----34
24.void main(){int a,n,s=0;printf(“Input a: “);scanf(”%d”,&a);printf(“Input n:”);scanf("%d",&n);while(n>=0){s=an+s;a=a10;n–;}printf(“s= %d\n”,s);}25.#include<stdio.h>main(){int mouth=0,tc=0,sum=0,tb=1,n,p;printf(“请输原创 2021-02-23 13:29:33 · 58 阅读 · 0 评论 -
19----23
19.#include"stdio.h"#include"math.h"void main(){int a,b,c;float p,s,l;printf(“please input a,b,c:\n”);scanf("%d%d%d",&a,&b,&c);if(a+b>c&&a+c>b&&b+c>a){l=a+b+c;p=l/2.0;s=sqrt(p*(p-a)(p-b)(p-c));printf(“l=%.原创 2021-02-22 13:45:47 · 47 阅读 · 0 评论 -
17
第十七题:计算个人所得税,假设个人所得税为:税率*(工资-1600)。请编写程序计算应缴的所得税,其中税率定义为:(1)当工资不超过1600时,税率为0;(2)当工资在区间(1600,2500]时,税率为5%;(3)当工资在区间(2500,3500]时,税率为10%;(4)当工资在区间(3500,4500]时,税率为15%;(5)当工资超过4500时,税率为20%。#include"stdio.h"void main(){float tax,salary;printf(“please i原创 2021-02-22 11:38:28 · 53 阅读 · 0 评论 -
16
#include"stdio.h"void main(){int a,b,c,min;printf(“please input the a,b and c:\n”);scanf("%d%d%d",&a,&b,&c);if(a<b){if(a<c)min=a;elsemin=c;}else{if(b<c)min=b;elsemin=c;}printf(“the min is %d\n”,min);}原创 2021-02-21 14:25:02 · 43 阅读 · 0 评论 -
15
#include"stdio.h"void main(){int a,i,b,n;printf(“There are following friendly-numbers pair smaller than 3000:\n”);for(a=1;a<=3000;a++){for(b=0,i=1;i<=a/2;i++)if(!(a%i))b+=i;for(n=0,i=1;i<=b/2;i++)if(!(b%i))n+=i;if(n==a&&a<b原创 2021-02-21 14:24:37 · 52 阅读 · 0 评论 -
14
#include"stdio.h"void main(){int n;int i,j,k;int count=0;while(scanf("%d",&n)){for(i=1;i<=n;++i)for(j=i+1;j<=n;++j)for(k=j+1;k<=n;++k)if(ii+jj==k*k){printf("[%d,%d,%d], ",i,j,k);count++;}printf(“total number: %d\n”,count);}}原创 2021-02-21 14:23:48 · 40 阅读 · 0 评论 -
13
#include <stdio.h>void main(){int cock,hen,chicken;for(cock=0;cock<=20;cock++)for(hen=0;hen<=33;hen++){chicken=100-cock-hen;if(5cock+3hen+chicken/3.0==100)printf(“cock=%2d,hen=%2d,chicken=%2d\n”,cock,hen,chicken);}}原创 2021-02-21 14:23:11 · 56 阅读 · 0 评论 -
12
#include <stdio.h>#include <math.h>int main(){int n;int i,j,k;int count=0,s; //s是个标志位,如果是素数,让s=1;如果不是素数,让s=0 。printf(“请输入一个正整数N:\n”);scanf("%d",&n);for(i=2;i+2<=n;i++ ){s = 1; /* 先假设i是素数 /k = sqrt(i);for(j=2;j<=k原创 2021-02-21 14:22:42 · 62 阅读 · 0 评论 -
11
第十一题:编写一个程序输出一定范围内所有的完全数,如果一个数等于它的因子之和,则称该数为“完全数”。#include"stdio.h"void main(){int m,n;int sum,i,j;printf(“Please enter the range [m,n]:\n”);scanf("%d%d",&m,&n);printf("\n");printf(“the Perfect number is :\n”);for(i=m;i<=n;i++){sum=0原创 2021-02-21 14:21:31 · 56 阅读 · 0 评论 -
10
第十题:输出所有的"水仙花数"。所谓"水仙花数"是指这样的一个三位数:其各位数字的立方和等于该数本身。例如:371是一个"水仙花数",371=33+73+1^3。#include"stdio.h"void main(){int i,j,k,n;printf(“The Narcissistic number:\n”);printf("\n");for(n=100;n<1000;n++){i=n/100;j=(n-100i)/10;k=n%10;if(iii+jjj+kk*k==原创 2021-02-21 14:20:44 · 99 阅读 · 0 评论 -
9
第九题:判断一个数是否为"水仙花数",所谓"水仙花数"是指一个三位数其各位数字的立方和等于该数本身。#include"stdio.h"void main(){int i,j,k,n;printf(“please input the n:\n”);scanf("%d",&n);printf("\n");i=n/100;j=(n-100*i)/10;k=n%10;if(i*i*i+j*j*j+k*k*k==n) printf("the %d is Narcis原创 2021-02-21 14:19:35 · 62 阅读 · 0 评论 -
8
第八题:求出1-N中的所有素数#include"stdio.h"void main(){int i,j,n;int count=0;printf(“请输入n:\n”);scanf("%d",&n);for(i=2;i<=n;i++){for(j=2;j<i;j++)if(i%j0)break;if(ji){printf("%d\t",i);count++;}}printf("\n1~%d之间有%d个素数!!!\n",n,count);}...原创 2021-02-21 14:18:57 · 61 阅读 · 0 评论 -
7
第七题:计算下面的分段函数,#include"stdio.h"void main(){int x;printf(“please input the x:\n”);scanf(“x=%d”,&x);if(x==0)printf(“y=0\n”);elseprintf(“y=%f\n”,1.0/x);}原创 2021-02-21 14:17:10 · 89 阅读 · 0 评论 -
1
***标题 ***输出Hello World!#include<stdio.h>main(){printf(“Hello Word!”);}原创 2021-02-01 14:15:00 · 77 阅读 · 0 评论 -
6
计算如下分段函数#include"stdio.h"void main(){int x,y;printf(“please input the x:\n”);scanf(“x=%d”,&x);if(x<1)y=x;else if(x<10)y=2x-1;elsey=3x-1;printf(“y=%d\n”,y);}原创 2021-02-14 14:15:36 · 55 阅读 · 0 评论 -
5
编写1+1/2+1/3+…+1/n计算程序#include"stdio.h"void main(){int i=1,n;float sum=0;printf(“please input the n:\n”);scanf("%d",&n);while(i<=n){sum+=1.0/i;i++;}printf(“the result is %.5f\n”,sum);}原创 2021-02-14 13:20:48 · 98 阅读 · 0 评论