Академический Документы
Профессиональный Документы
Культура Документы
0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8,18,9,20...
N= 8 -> 3
N=12 -> 5
N=21 -> 20
N=13 -> 12
N=15 -> 14
*/
#include <stdio.h>
int main()
int N,end;
scanf("%d",&end);
for(N=1;N<=end;N++)
if(N%2==0)
printf("%d ",(N/2)-1);
else
printf("%d ",N-1);
return 0;
2)
/*1,2,1,3,2,5,3,7,5,11,8,13,13,17......
N=10 ->11
N=14 ->17
N=5 -> 2
#include<stdio.h>
#include<math.h>
int main()
int N,end;
scanf("%d",&end);
for(N=1;N<=end;N++)
if(N%2==0)
int count=0,num=2,flag=0,i;
while(count!=N/2)
for(i=2;i<=sqrt(num);i++)
if(num%i==0)
flag=1;
break;
if(flag==0)
count++;
num++;
flag=0;
printf("%d ",num-1);
else
if(N==1||N==3)
printf("1 ");
else
int num1=1,num2=1,num3,i;
for(i=3;i<=(N/2)+1;i++)
num3=num1+num2;
num1=num2;
num2=num3;
printf("%d ",num3);
return 0;
3)
#include<stdio.h>
int main()
int num1=1,num2=2,num3,i,N;
scanf("%d",&N);
for(i=3;i<=N;i++)
num3=num1+num2;
num1=num2;
num2=num3;
printf("%d ",num3);
return 0;
4)
1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187.........
#include<stdio.h>
#include<math.h>
int main()
int N,ans;
scanf("%d",&N);
if(N%2==0)
ans=pow(3,(N-1)/2);
printf("%d",ans);
else
ans=pow(2,(N-1)/2);
printf("%d",ans);
return 0;
4)
/*
cation:
1) Accept one integer number (which will be 2 digit number) from STDIN
3) Print the resulting number to STDOUT For example, if the input value is 21,
the program will print 12 to STDOUT it can be assumed that the input value will
eg: 46
46%10 ->6
46/10 ->4
6*10+4
46%10*10+46/10
*/
#include<stdio.h>
int main()
int num;
scanf("%d",&num);
printf("%d",(num%10)*10+(num/10));
return 0;
5)
/*
reverse order.
For example, if the input string is aaaaEEGccCCCxEEf , the output should be fExCcGEa
The input string of characters should be read from STDIN and the result should be
written to STDOUT Other than the required output, no other characters / string or
You can assume that the input string length will not exceed 30 characters
*/
#include<stdio.h>
int main()
char str[30],ans[30];
int ind,i=0;
scanf("%s",str);
for(ind=0;str[ind]!='\0';ind++)
if(str[ind]!=str[ind+1])
ans[i++]=str[ind];
for(ind=i-1;ind>=0;ind--)
printf("%c",ans[ind]);
return 0;