华为机试题六

/*查找非素数
#include
using namespace std;
int fun(int m)
{
	int i;
	for(i=2;i>m;
	for (i=0;i<=m;i++)
	{
		if(fun(i)==0)
			cout<
using namespace std;
void main()
{
	int a[30],m;
	int i=0;
	int j,k;
	int count = 0;
	cin>>m;
	while (m)
	{
		a[i]=m&0001;
		i++;
		m=m/2;
	}
	j=i;
	for (i=j-1;i>=0;i--)
	{
		if(a[i]==1) 
		{
			k=i;
			break;
		}
	}
	for(i=0;i
using namespace std;
void main()
{
    int m,n;
	cin>>m>>n;
    int r=m%n;
	while (r)
	{
      m=n;
      n=r;
	  r=m%n;
	}
	cout<  
using namespace std;  
void main()  
{  
    char a,s[100];  
    int count = 0;  
    int i,j;  
    gets(s);  
    for (i=0;i
#include 
using namespace std;
#define N 6
void main()
{
	char a[10][N];
	int i,j;
	i=0;
    while (scanf("%s",a[i])!= EOF)
    {
        cout<=0;j--)
		{
			cout<
#include 
using namespace std;
void main()
{
	char a[1024],s;
	int i,j,k;
	scanf("%s",a);
	for (i=0;i
using namespace std;
void main()
{
	int N,M;
	int *a;
	int i,j,k,m,temp;
	char s1;
	cin>>N>>M;
    a = (int *)malloc(N*sizeof(int));
    for(i=0;i>a[i];
	for(j=0;j>s1;
		cin>>k>>m;
		if (s1 == 'Q')
		{
			temp=0;
			for (i=k;i<=m;i++)
			{
               if (a[i]>temp)
               {
				   temp=a[i];
               } 
			}
			cout<
#include 
using namespace std;
void main()
{
	char a[50];
	int i;
	gets(a);
	for (i=0;i='A' && a[i]<='U')
		{
			a[i] = a[i] + 37;
		}
		else if (a[i] =='V' )
		{
             a[i] = 'a';
		}
		else if (a[i] =='W' )
		{
			a[i] = 'b';
		}
		else if (a[i] =='X' )
		{
			a[i] = 'c';
		}
		else if (a[i] =='Y' )
		{
			a[i] = 'd';
		}
		else if (a[i] =='Z' )
		{
			a[i] = 'e';
		}
	}
	puts(a);
}
*/
/*    尼科彻斯定理
#include 
using namespace std;
void main()
{
	int m,i;
	cin>>m;
	int m3 = m*m*m;
	int	m2=m*m;
	int ans;
	if (m%2 == 0)
	{
		ans = 0;
		for (i=0;i=0;i--)
			{
				cout<0;i--)
		   {
			 cout<
using namespace std;
void main()
{
	int m,i;
	cin>>m;
	int m3 = m*m*m;
	int k= m*(m-1)+1;
	int sum = 0;
	for (i=0;i
using namespace std;
int a[7] = {1,2,5,10,20,50,100};
int fun(int n,int i)
{
	if(n==1 || i==0) 
		return 1;
	if(n<0 || i<0)
		return 0;
	return fun(n-a[i],i)+fun(n,i-1);
}
void main()
{
	int n;
    int i;
	cin>>n;
	while (n != 0)
	{
		for (i=6;i>=0;i--)
		{
			if (n>=a[i])
			{
				break;
			}
		}
        cout<>n;
	}
}
*/

 部分初级题集合

转载于:https://www.cnblogs.com/zlj830/p/4717152.html

你可能感兴趣的:(华为机试题六)