Rohit Rumani
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
{#include<bits/stdc++.h>
using namespace std;
int main()
{
long int tc,t,i,n,p;
scanf("%d",&tc);
while(tc--)
{
scanf("%ld",&n);long int a[n];
for(i=0;i<n;i++)
scanf("%ld",&a[i]);
//sort(a,a+n);
for(i=0;i<n-1;i++)
{
if(i%2==0)
{
if(a[i]>=a[i+1])
{
t=a[i];a[i]=a[i+1];a[i+1]=t;
}
}
else if(i%2!=0)
{
if(a[i]<=a[i+1])
{
p=a[i];a[i]=a[i+1];a[i+1]=p;
}
}
}
for(i=0;i<n;i++)
printf("%ld ",a[i]);
printf("\n");
}
return 0;
}}
Comment hidden because of low score. Click to expand.
0
of 0 vote
#include<stdio.h>
#include<conio.h>
int main()
{
int i,a[15],n;
scanf("%d",&n);
a[0]=1
for(i=1;i<=n;i++)
{
a[i]=a[i-1]+i*i;
}
for(i=0;i<=n;i++){
printf("%d",a[i]);
}
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
if(k>n)
- Rohit Rumani February 06, 2017k%=n;//where k is number of rotation and m is index
while(q--)
{
cin>>m;
j=m-k;
if(j<0)
cout<<a[n+j]<<endl;
else
cout<<a[j]<<endl;
}