C++ common practice questions

// output the number of daffodils
intmain()
{
	int i = 0;
	int j = 0;
	int k = 0;
	for (int m = 100; m < 1000; m++)
	{
		i = m % 10;
		j = m /10 % 10;
		k = m / 100;
		if (i*i*i + j*j*j + k*k*k == m)
			printf("%d  ", m);
	}
	system("pause");
	return 0;
}
//1234, output 4321
intmain()
{
	int num = 0;
	scanf("%d\n", &num);
	int key = 0;
	while (num)
	{
		key = num% 10;
		printf("%d  ", key);
		num = num / 10;
	}
	system("pause");
	return 0;
}
 
 
//Output the number of 9s between 1 and 100
intmain()
{
	int count = 0;
	for (int i = 1; i <= 100; i++)
	{
		if (i % 10 == 9)
			count++;
		if (i / 10 == 9)
			count++;
	}
	printf("%d\n", count);
	system("pause");
	return 0;
}

 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325889001&siteId=291194637