today laster
This commit is contained in:
parent
9a87ba69d6
commit
6d0e343276
1
3.14.cpp
1
3.14.cpp
@ -73,4 +73,5 @@ int main(){
|
|||||||
cout <<"结果是:"<<C<<danwei<<endl;
|
cout <<"结果是:"<<C<<danwei<<endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
87
class.cpp
Normal file
87
class.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
//do...while
|
||||||
|
//计算各个数位之和
|
||||||
|
|
||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void while_1();
|
||||||
|
void do_while();
|
||||||
|
void huiwenshu();
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
int choose;
|
||||||
|
cout <<"选择"<<endl;
|
||||||
|
cout <<"1.do...while"<<endl;
|
||||||
|
cout <<"2.while"<<endl;
|
||||||
|
cout <<"3.回文数"<<endl;
|
||||||
|
cin >>choose;
|
||||||
|
|
||||||
|
if (choose == 2)
|
||||||
|
{
|
||||||
|
while_1();
|
||||||
|
}else if (choose == 1)
|
||||||
|
{
|
||||||
|
do_while();
|
||||||
|
}else if (choose == 3)
|
||||||
|
{
|
||||||
|
huiwenshu();
|
||||||
|
}else{
|
||||||
|
cout <<"输入错误!"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_while(){
|
||||||
|
cout <<"已进入do..while"<<endl;
|
||||||
|
int CIN,andy;
|
||||||
|
int a,b,c;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cin >>CIN;
|
||||||
|
a = CIN / 100;
|
||||||
|
b= CIN / 10 % 10;
|
||||||
|
c = CIN % 10;
|
||||||
|
|
||||||
|
andy = a+b+c;
|
||||||
|
cout <<andy<<endl;
|
||||||
|
} while (CIN > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void while_1(){
|
||||||
|
cout <<"已进入while"<<endl;
|
||||||
|
int CIN2,andy,a,b,c;
|
||||||
|
|
||||||
|
while (CIN2 > 0)
|
||||||
|
{
|
||||||
|
cin >>CIN2;
|
||||||
|
a = CIN2 / 100;
|
||||||
|
b = CIN2 / 10 % 10;
|
||||||
|
b = CIN2 % 10;
|
||||||
|
andy = a+b+c;
|
||||||
|
cout <<andy<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void huiwenshu(){
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int n,ge,number = 0,number2;
|
||||||
|
cin >>n;
|
||||||
|
number2 = n;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ge = n%10;
|
||||||
|
number = number * 10 + ge;
|
||||||
|
n = n / 10;
|
||||||
|
} while (n > 0);
|
||||||
|
|
||||||
|
if (number != number2)
|
||||||
|
{
|
||||||
|
cout <<"NO!"<<endl;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
cout <<"YES!"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user