1.
#include<stdio.h>
double min(double a, double b);
int main(void)
{
double x, y;
scanf("%lf%lf", &x, &y);
printf("%lf", min(x, y));
return 0;
}
double min(double a, double b)
{
return a < b ? a : b;
}
2.
#include<stdio.h>
void chline(char ch, int i, int j);
int main(void)
{
char ch;
int a, b;
scanf("%c%d%d", &ch, &a, &b);
chline(ch, a, b);
return 0;
}
void chline(char ch, int i, int j)
{
for (int k = 1; k < i; k++)
printf(" ");
for (; i <= j; i++)
printf("%c", ch);
}
3
#include<stdio.h>
void fun(char ch, int a, int b);
int main(void)
{
char ch;
int x, y;
scanf("%c%d%d", &ch, &x, &y);
fun(ch, x, y);
return 0;
}
void fun(char ch, int a, int b)
{
for (int i = 0; i < a; i++)
{
for (int i = 0; i < b; i++)
printf("%c", ch);
printf("\n");
}
}
4.
#include<stdio.h>
double fun(double a, double b);
int main(void)
{
double x, y;
scanf("%lf%lf", &x, &y);
printf("%lf", fun(x, y));
return 0;
}
double fun(double a, double b)
{
double c;
c = 1 / ((1 / a + 1 / b) / 2);
return c;
}
5.
#include<stdio.h>
void larger_of(double *a, double *b);
int main(void)
{
double x, y;
scanf("%lf%lf", &x, &y);
larger_of(&x, &y);
printf("%lf %lf\n", x, y);
return 0;
}
void larger_of(double *a, double *b)
{
*a = *b = *a > *b ? *a : *b;
}
6.
#include<stdio.h>
#include<ctype.h>
int fun(char ch);
int main(void)
{
char ch;
scanf("%c", &ch);
printf("%c\'s position is %d\n", ch, fun(ch));
return 0;
}
int fun(char ch)
{
int a;
char ch1;
if (isalpha(ch))
{
printf("%c is a alpha.\n", ch);
ch1 = toupper(ch);
a = ch1 - 65 + 1;
return a;
}
else
return -1;
}
7.
#include<stdio.h>
#include<math.h>
double power(double x, int y);
int main(void)
{
double a;
int b;
while (scanf("%lf%d", &a, &b) == 2)
{
printf("%lf\n", power(a, b));
}
return 0;
}
double power(double x, int y)
{
double c = 1;
if (y > 0)
{
for (int i = 0; i < y; i++)
c *= x;
return c;
}
else if (y < 0)
{
for (int i = 0; i < -y; i++)
c /= x;
return c;
}
else if (x != 0)
return 1;
else
return 1 / x;
}
8.
*
9.
这里写代码片