求一个数字,此数字有如下特点:
1.最后两位是34
2.此数是34的整数倍。
3.此数各位之和为34。
求满足此三条件最小整数是?~_~
看哪位高人还记得这些东西?不要骂我无聊哦!!!

解决方案 »

  1.   

    long n = 34;
    const int key = 34; CString str, strLast2, str1;
    long  nAdd, nLen;
    while(1)
    {
    str.Format("%d", n);
    strLast2 = str.Right(2); nLen = str.GetLength();
    nAdd = 0;
    for(int i=0; i<nLen; i++)
    {
    str1.Format("%c", str.GetAt(i));
    nAdd += atoi(str1); 
    }

    if( n%key != 0 || strLast2 != "34" || nAdd != key)
    {
    n++;
    continue;
    }
    else
    break; }
    str.Format("%d", n);
    AfxMessageBox(str);
      

  2.   

    就算代数忘了,for循环还是不会忘的