for n=12 output is 1,2,3,4,5,6,7,8,9,11,22,33
#include <bits/stdc++.h>
using namespace std;
main()
{
long n,i,k,k1;
while(cin>>n)
{
for(i=1; i<=n; i++)
{
if(i<=9)
cout<<i<<" ";
else if(i<=18)
{
k=i-9;
cout<<k*11<<" ";
}
else
{
k=(i-19)%10;
k1=(i-k)/10;
while(k1>=10)
{
k1/=10;
}
printf("%ld%ld%ld ",k1,k,k1);
}
}
}
}
#include <bits/stdc++.h>
using namespace std;
main()
{
long n,i,k,k1;
while(cin>>n)
{
for(i=1; i<=n; i++)
{
if(i<=9)
cout<<i<<" ";
else if(i<=18)
{
k=i-9;
cout<<k*11<<" ";
}
else
{
k=(i-19)%10;
k1=(i-k)/10;
while(k1>=10)
{
k1/=10;
}
printf("%ld%ld%ld ",k1,k,k1);
}
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন