面試題目:定義一結(jié)構(gòu)體數(shù)組表示分?jǐn)?shù),并求兩個(gè)分?jǐn)?shù)相加之和
解: #include
#include
struct fenshu
{
int fz;
int fm;
};
main()
{
int I;
struct fenshu f1,f2,result;
printf(“input f1.fz:”);
scanf(“%d”,&f1.fz);
printf(“input f1.fm:”);
scanf(“%d”,&f1.fm);
printf(“input f2.fz:”);
scanf(“input f2.fz);
printf(“input f2.fm:”);
scanf(“%d”,&f2.fm);
result.fm=f1.fm*f2.fm;
result.fz=f1.fz*f2.fm+f1.fm*f2.fz;
I=result.fz;
While((result.fz%i)||(result.fm%i))
i–;
result.fm=result.fm/i;
result.fz=result.fz/i;
printf(“result.fz is:%d”,result.fz);
printf(“result.fm is:%d”,result.fm);
}
【面試題目:定義一結(jié)構(gòu)體數(shù)組表示分?jǐn)?shù),并求兩個(gè)分?jǐn)?shù)相加之和】相關(guān)文章:
小學(xué)分?jǐn)?shù)相加應(yīng)用題10-02
Java數(shù)組定義常用方法11-12
考研初試科目考卷結(jié)構(gòu)及分?jǐn)?shù)12-25
JavaScript數(shù)組的定義及數(shù)字操作方法11-16
由宏定義來(lái)實(shí)現(xiàn)求兩個(gè)數(shù)的乘積和商數(shù)之筆試實(shí)例12-14
求面試的技巧01-01