0410
This commit is contained in:
parent
a4c3b49af6
commit
984d2c30f0
16
0410/1.c
Normal file
16
0410/1.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#define for_i(i, range, inner) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for (i = 0; i < range; i++) \
|
||||||
|
inner; \
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int n, avg = 0, count = 0;
|
||||||
|
int a[1005];
|
||||||
|
scanf("%d", &n);
|
||||||
|
for_i(i, n, printf("%d ", (int)(600 * cos(i * 0.35))));
|
||||||
|
return 0;
|
||||||
|
}
|
24
0410/2.c
Normal file
24
0410/2.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#ifndef bool
|
||||||
|
#define bool int
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
#endif
|
||||||
|
#define putbool(x) (printf("%s", (x) ? "TRUE" : "FALSE"))
|
||||||
|
|
||||||
|
int get_char(char *s) {
|
||||||
|
*s = getchar();
|
||||||
|
return *s != EOF && *s != '\n' && *s != '\r';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char c;
|
||||||
|
while (get_char(&c)) {
|
||||||
|
if (c > 'z' || c < 'a') {
|
||||||
|
putbool(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
putbool(true);
|
||||||
|
return 0;
|
||||||
|
}
|
18
0410/3.c
Normal file
18
0410/3.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int get_char(char *s) {
|
||||||
|
*s = getchar();
|
||||||
|
return *s != EOF && *s != '\n' && *s != '\r';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char c;
|
||||||
|
int count = 0;
|
||||||
|
while (get_char(&c)) {
|
||||||
|
if (c == ' ') {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("%d\n", count);
|
||||||
|
return 0;
|
||||||
|
}
|
16
0410/4.c
Normal file
16
0410/4.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int get_char(char *s) {
|
||||||
|
*s = getchar();
|
||||||
|
return *s != EOF && *s != '\n' && *s != '\r';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char c;
|
||||||
|
int count = 0;
|
||||||
|
while (get_char(&c)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
printf("%d\n", count);
|
||||||
|
return 0;
|
||||||
|
}
|
27
0410/5.c
Normal file
27
0410/5.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int *x;
|
||||||
|
int N, sum = 0;
|
||||||
|
scanf("%d", &N);
|
||||||
|
x = malloc(N * sizeof(int));
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < N; i++) {
|
||||||
|
x[i] = 100 * sin(i * 0.05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < N; i++) {
|
||||||
|
sum += x[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("%d", sum);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
27
0410/6.c
Normal file
27
0410/6.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
float *x;
|
||||||
|
int N;
|
||||||
|
float sum = 0;
|
||||||
|
scanf("%d", &N);
|
||||||
|
x = malloc(N * sizeof(float));
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < N; i++) {
|
||||||
|
x[i] = 100 * cos(i * 0.01);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < N; i++) {
|
||||||
|
sum += x[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("%.2f", sum);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
19
0410/7.c
Normal file
19
0410/7.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#define for_i(i, range, inner) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for (i = 0; i < range; i++) \
|
||||||
|
inner; \
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a[4][4], *p = (int *)a, n, sum = 0;
|
||||||
|
scanf("%d", &n);
|
||||||
|
for_i(i, 16, p[i] = n + i);
|
||||||
|
for_i(i, 4, {
|
||||||
|
sum += a[i][i];
|
||||||
|
sum += a[i][3 - i];
|
||||||
|
});
|
||||||
|
printf("%d\n", sum);
|
||||||
|
return 0;
|
||||||
|
}
|
15
0410/8.c
Normal file
15
0410/8.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
const char month[][5] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int n, *ptr;
|
||||||
|
scanf("%d", &n);
|
||||||
|
if (n >= 1 && n <= 12) {
|
||||||
|
printf("%s", month[n - 1]);
|
||||||
|
} else {
|
||||||
|
printf("Error");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user