c++初学者不会写,请各位看看吧

img


是上下两道题
谢谢各位大佬了

1

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int a,b,c,max,min;
    scanf("%d%d%d", &a, &b, &c);
    max = a>b ? a : b;
    max = c>max ? c : max;
    min = a<b ? a : b;
    min = c<min ? c : min;
    double s = pow(max-min,abs(a-b));
    printf("%lf\n",s);
    return 0;
}

img

2

#include<stdio.h>
void date(int n)
{
    int i,k=9;
    char s[11];
    for (i = 0; i < 8; i++)
    {
        s[k--] = n%10 + '0';
        if (i==1 || i==3)
            s[k--] = '-';
        n /= 10;
    }
    s[10] = '\0';
    printf("%s\n", s);
}

int main()
{
    int n;
    scanf("%d", &n);
    date(n);
   return 0;
}

img