编写一个C ++代码,提示用户插入一个数字(只有一个数字)的四位数字,然后按相反的顺序打印数字。 [英] Write a C++ code that prompt a user to insert a number (just only one number) of four digits then print the number in reverse order.

查看:121
本文介绍了编写一个C ++代码,提示用户插入一个数字(只有一个数字)的四位数字,然后按相反的顺序打印数字。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个C ++代码,提示用户插入四位数字(只有一个数字),然后按相反的顺序打印数字。



求助我

解决方案

你应该做自己的功课。

这真的是一项简单的任务,有几种方法可以对其进行编码。用你的创造力给我们惊喜!

顺便说一句:在这里只询问具体问题。


试试这个:



  int  main()
{
bool intEntered = false ;
char 输入[ 255 ];
int number;

执行 {
cout<< 输入numbet:;
cin>>输入;
string s = input;
number = atoi(s.c_str());
if (number == 0
cout<< Null is notowed :);
else
intEntered = true ;

} while (!intEntered);
}





然后使用for循环从最后一位数字读取。瞧!!!!


Write a C++ code that prompt a user to insert a number (just only one number) of four digits then print the number in reverse order.

Help Me Please

解决方案

You should do your own homework.
That's really an easy task and there are several ways to code it. Surprise us with your creativity!
By the way: ask here only specific questions.


Try With this:

int main ()
{
	bool intEntered = false;
	char input[255] ;
	int number;

	do{
	cout<<"Input numbet: ";
	cin >> input;
	string s = input;
	number = atoi(s.c_str());
	if ( number == 0 )
	cout << "Null is not alowed :) ";
	else
		intEntered = true;

	}while(!intEntered);
}



Then use for loop to read from last digit. Voila!!!!


这篇关于编写一个C ++代码,提示用户插入一个数字(只有一个数字)的四位数字,然后按相反的顺序打印数字。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆