c语言计算长方形的面积和周长.doc
计算长方形的面积和周长#include "stdio.h"main()int chang;int kuan;int mianji;int zhouchang;printf("请输入长方形的长n");scanf("%d",&chang);printf("请输入长方形的宽n");scanf("%d",&kuan);if (chang<=0 | kuan<=0)printf("您输入的长或宽不合法");printf("请重新输入长方形的长n"); scanf("%d",&chang); printf("请重新输入长方形的宽n"); scanf("%d",&kuan);mianji=chang*kuan; zhouchang=2*chang+2*kuan;printf("长方形的面积为:%dn长方形的周长为:%dn",mianji,zhouchang);else mianji=chang*kuan; zhouchang=2*chang+2*kuan;printf("长方形的面积为:%dn长方形的周长为:%dn",mianji,zhouchang);mianji=chang*kuan;zhouchang=2*chang+2*kuan;