在下面的代码中,我是否有可能接受多个输入,进行一些计算(如最后一个字符)并在最后打印..然后再次输入直到 5 次?
#include <iostream>
using namespace std;
int main ()
{
char name;
int i=0;
while(i != 5){
while(!(name != '<' || name != '>')){
cin>>name;
//do some calculation with the inputs
//cout<<name;
}
i++;
cout<<name;
//print the result of calculation this loop
}
}
出于某种原因,我不允许使用string, or array, or break, 以及除iostream. 是否可以使用循环?什么是替代品?
编辑::在上面的代码中,我想确定最后输入的内容。如果我输入asdf>然后我得到>>>>>。我希望它打印>并返回循环并要求我再拍一张。