int main() {

	int T, a;
	Number N;

	cin >> T;
	for (int i = 0; i < T; i++) {
		cin >> a;
		N.reset();
		for (int j = 2; j <= a; j++)
			N.multi(j);
		N.display();
		cout << endl;
	}

	return 0;
}
Exemple #2
0
//-------------------------------------------------------------------------------------------------
// FuntionName: readCharacter
// Purpose: read each character input from stdin, then add it to number object
//          case charater is ' ' => build number.
//          case charater is '\n' => Calculate a sum of squares for Line, then loop for other Line
//          case charater is 'q' => end of test.
//          Other case will be reject.
//--------------------------------------------------------------------------------------------------
bool readCharacter( Number& num, char*& buff, char& sign, bool& isInputIncorrect )
{
   char c = getchar();
   if( c == ENTER )
   {
      putc('\n',stdout);
   }
   else if( c != END_PROGRAM )
   {
      putc(c,stdout);
   }

   if( (c >= '0' && c <= '9') || c == ENTER || c == END_PROGRAM || c == '-' || c == ' ')
   {
      if(c == END_PROGRAM)
      {
         sign = END_PROGRAM;
         return true;
      }
      else
      {
         if( c != ' ' && c != ENTER )
         {
            num.setListCharacter(c);
         }
         else
         {
            bool ret = num.setNumber();
            if(ret)
            {
               countLine += num.getNumber() * num.getNumber();
               num.reset();
            }
            else
            {
               num.reset();
               countLine = 0;
               isInputIncorrect = true;
               return true;
            }

            if( c == ENTER )
            {
               char buf[10];
               sprintf(buf,"%d\n",countLine);
               appenData(buff,buf);
               countLine = 0;
            }
         }

         readCharacter(num, buff, sign, isInputIncorrect);
      }
   }
   else
   {
      num.reset();
      countLine = 0;
      isInputIncorrect = true;
      return true;
   }
}