取余数(%)

//取余数(%)
#include<iostream>
using namespace std;
int main(){
    int apple=60;            //苹果 
    int people=7;            //人数 
    int apple_remain;        //平分后还剩几个苹果 
    if(people==0)
        cout<<"错误!"<<endl;
    else{
        apple_remain=apple%people; //取余
        cout<<"平均分配后还剩"<<apple_remain<<"个苹果"<<endl;
         
    } 
    return 0;
} 

 

posted @ 2018-06-17 10:30  无心小男  阅读(277)  评论(0编辑  收藏  举报