วันพุธที่ 9 พฤศจิกายน พ.ศ. 2559
C++ หาเลขโดด ที่สลับตำแหน่งกัน
int n, o, t, th, f, fi, s;
cout << "Enter Input : ";
cin >> n;
if (n >= 0 && n <= 9999999)
{
s = n % 1000000 / 100000;
fi = n % 100000 / 10000;
f = n % 10000 / 1000;
th = n % 1000 / 100;
t = n % 100 / 10;
o = n % 10 / 1;
if (s == 0 && fi != 0)
cout << o << "," << t << "," << th << "," << f << "," << fi << endl;
else if (s == 0 && fi == 0 && f != 0)
cout << o << "," << t << "," << th << "," << f << endl;
else if (s == 0 && fi == 0 && f == 0 && th != 0)
cout << o << "," << t << "," << th << endl;
else if (s == 0 && fi == 0 && f == 0 && th == 0 && t != 0)
cout << o << "," << t << endl;
else if (s == 0 && fi == 0 && f == 0 && th == 0 && t == 0 && o != 0)
cout << o << endl;
else
cout << o << "," << th << "," << t << "," << f << "," << fi << "," << s << endl;
}
else
{
cout << "Please Enter number 0-9999999" << endl;
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น