实验二
一
#include<stdio.h>
int main(){
char a,b,c,d,e;
a = getchar();
b = getchar();
c = getchar();
d = getchar();
e = getchar();
putchar(a);
putchar(b);
putchar(c);
putchar(d);
putchar(e);
return 0;
}
二
#include<stdio.h>
int main(){
int year;
printf("input the year");
scanf("%d",&year);
if(year%4==0&&year%100!=0||year%400==0)
printf("year:%d,month:2,days:29\n",year);
else
printf("year:%d,month:2,days:28\n",year);
return 0;
}
三
#include<stdio.h>
#include<stdlib.h>
int main(){
int a, b, c; printf("input three numbers:\n"); scanf("%d", &a); scanf("%d", &b); scanf("%d", &c);
if (a + b > c && a + c > b && b + c > a) {
if (a == b || a == c || b == c) {
if (a == b && b == c) {
printf("equilateral triangle\n"); }
else if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) {
printf("isosceles right triangle\n"); }
else {
printf("isosceles triangle\n"); } }
else if(a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) { printf("right triangle\n"); }
else {
printf("ordinary triangle\n"); } }
else {
printf("unable to get a triangle\n"); }
system("pause");
return 0;}
四
#include <stdio.h>
#include <math.h>
int main(){
double a,rate,tax,profit;
scanf("%lf",&a);
if(a>=5000){
rate = 0.15;}
else if(2000<=a<5000){
rate = 0.10;}
else if(1000<=a<2000){
rate = 0.08;}
else if(500<=a<1000){
rate = 0.05;}
else{
rate = 0.00;}
tax = a*rate;
profit = a - tax;
printf("%lf\n%lf\n%lf\n",rate,tax,profit);
return 0;
}
posted on 2019-04-22 15:33 p201821440017 阅读(132) 评论(0) 编辑 收藏 举报