-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlb11.c
168 lines (153 loc) · 3.28 KB
/
lb11.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
int main()
{
int num;
printf("input:");
scanf("%d",&num);
printf("output:");
put(num);
printf("\n");
return 0;
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
double a,b;
printf("please input two numbers:");
scanf("%lf,%lf",&a,&b);
printf("Output");
printf("\na=%.6lf,b=%.6lf\n",a,b);
}
/////////////////////////////////////////////////////////////////////
#include<stdio.h>
void main()
{
char a;
printf("Input a lowercase letter: ");
scanf("%c",&a);
printf("Output:");
printf("%c(%d)\n",a,a);
a=a-32;
printf("%c(%d)\n",a,a);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <math.h>
void main()
{
int l,C;
double p,S;
printf("Input a side of triangle: ");
scanf("%d",&l);
C=l*3;
p=C/2.0;
S=sqrt(p*(p-l)*(p-l)*(p-l));
printf("Output: ");
printf("The area of triangle is %.2lf, the circle of triangle is %d.\n",S,C);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
char ch;
printf("Input a character: ");
ch=getchar();
printf("Output: ");
printf("%x\n",ch);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
int l,S,V;
printf("Input a side of cube: ");
scanf("%d",&l);
S=(l*l)*6;
V=l*l*l;
printf("Output: ");
printf("\nThe volume of cube is %d, the surface area of cube is %d.\n",V,S);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
double x,y,R;
int z ;
printf("please input x,y,z: ");
scanf("%lf,%lf,%d",&x,&y,&z);
R=x+z%3*(int)(x+y)%2/4;
printf("\nOutput:%.6lf\n",R);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
int y,m,d;
printf("\nplease input a date: ");
scanf("%d-%d-%d",&y,&m,&d);
printf("Output: ");
printf("\nthe date is: %d/%d/%d\n",y,m,d);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
unsigned int n;
int a,b,c,d,m;
printf("Input a number with 4-digit: ");
scanf("%d",&n);
a=n/1000;
b=n%1000/100;
c=n%100/10;
d=n%10;
m=a+b+c+d;
printf("Output:\nsum=%d\n",m);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
#define PRICE 30
void main()
{
int num,total;
printf("please input num: ");
scanf("%d",&num);
total=PRICE*num;
printf("Output:");
printf("\ntotal=%d\n",total);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
int a,b,s;
printf("please input data: ");
scanf("%d %d",&a,&b);
s=a+b;
printf("Output: ");
printf("\n %d+ %d= %d\n",a,b,s);
}
/////////////////////////////////////////////////////////////////////
#include <stdio.h>
void main()
{
double r,h;
double C1,S,V;
printf("Input: ");
scanf("r=%lf,h=%lf",&r,&h);
C1=2*3.14*r;
S=3.14*r*r;
V=3.14*r*r*h;
printf("Output:");
printf("\nC1=%.2lf\nS=%.2lf\nV=%.2lf\n",C1,S,V);
}
/////////////////////////////////////////////////////////////////////
#include<stdio.h>
void main()
{
float F,c;
printf("Input the degree:");
scanf("%f",&F);
c=5*(F-32)/9;
printf("Output:");
printf("\nF(%.2f)=C(%.2f)\n",F,c);
}