求车速

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void Up(int speed[])
{
	int i;
	for (i = 4; i > 0; i--)
	{
		if (speed[i] == 10)
		{
			speed[i - 1]++;
			speed[i] = 0;
		}
		else break;
	}
}
int main()
{
	int speed[5] = { 9 ,5,8,5,9 };
	int i;
	do {
		speed[4]++;
		Up(speed);
		if (speed[0] == speed[4] && speed[1] == speed[3])
			break;
	} while (1);
	for (i = 0; i < 5; i++)
	{
		printf("%d ", speed[i]);
	}
	printf("\n");
	return 0;
}

posted @ 2023-05-08 21:00  258333  阅读(16)  评论(0编辑  收藏  举报