#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int s[1001];
int main()
{
int k,u=0,i;
scanf("%d", &k);
for (i = 100; i < 1000; i++)
{
int a = i / 100, b = i % 100 / 10, c = i % 10;
if (a * 10 + b % k == 0 && b * 10 + c % k == 0 && i % k == 0)
{
s[u] = i;
u++;
}
}
int len = (sizeof(s) / sizeof(s[0]));
sort(s, s + len);
for (i = 0; i < len; i++)
{
printf("%d\n", s[i]);
}
return 0;
}
输出不了结果,全是零,调试时候a,b,c三个变量有时候说是未定义标识符,有时候说是变量已被优化掉,因而不可用,不知道为什么
(头文件有点乱,因为只学了一点C语言但是想用sort语句)