#include<stdio.h>
double series(double r1,double r2);
double parallel(double r1,double r2);
int main()
{
double r1,r2;
int flag=0;
printf("\nR1:");
scanf("%lf",&r1);
printf("\nR2:");
scanf("%lf",&r2);
printf("\n连接方式(0=series;1=parallel):");
scanf("%d",&flag);
if(flag==0)
printf("%f\n",series(r1,r2));
else
printf("%f\n",parallel(r1,r2));
return 0;
}
double series(double r1,double r2)
{
double sum=r1+r2;
return sum;
}
double parallel(double r1,double r2)
{
double sum=1.0 / (1.0 / r1 + 1.0 / r2);
return sum;
}