Language C has the largest number of number of Retrograde

Title Description

Given n number, find out which number n, the number has the maximum number of Retrograde.
Set the number of reverse: that the same symbol, but each digit is inverse opposed. The inverse number of the integer counter 256 is 652, the inverse number counter is an integer from -873 to -3780.
The maximum number of Retrograde: refers to the maximum number of reverse counter corresponds to the number of each.
Required to have the maximum number of Retrograde numbers: each number at the time than the size, not the number than the original, but their number is set to compare against.

Entry

First enter a positive integer n (1 <= n <= 100), indicates the number of subsequent input data.
Then enters the n type int integer.

Export

N the number of output having the maximum number of reverse position.

Sample input Copy

10
-1235 -678 358 129 -36 349 -28 985 -343 589

Sample output Copy

589

Code

#include<stdio.h>
#include<math.h>
int main()
{
	int a[100],b[100],n,f[100];
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	for(int i=0;i<n;i++)
	{
		int s=0;

		b[i]=a[i];
		
		if(a[i]>=0)	
		{
			f[i]=1;
		}
		else 
		{
			f[i]=-1;
			a[i]=-a[i];
		}
		
		while(a[i]>0)
		{
			s=s*10+a[i]%10;
			a[i]=a[i]/10;
		}
		a[i]=s*f[i];
	}
	int j=0;
	
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[j])	j=i;
	}
	
	printf("%d",b[j]);
	return 0;
}
Published 47 original articles · won praise 29 · views 1473

Guess you like

Origin blog.csdn.net/Qianzshuo/article/details/103886817