#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
int N, M = 0;
for (N = 1; N <= 15; N++) {
if(N<10){
M = M + N * 10 + N;
}
else M = M + N * 100 + N;
cout << "N=" << N<<" ";
cout << "M=" << M << endl;
}
return 0;
}
运行结果如下:
特别注意的是:对于N的值要有个判断,如果N是个位数,那么NN=N*10+N;如果N是十位数,那么NN=N*100+N;
原文地址:https://www.cnblogs.com/rorelys/p/9734734.html
时间: 2024-10-17 12:26:50