kkkk
BAN USER#include <stdio.h>
#include <stdlib.h>
int valid(int n)
{
int temp = n / 100, first = n % 10, second = (n/10) % 10;
if(first <= second)
return 0;
while(temp > 0)
{
first = second;
second = temp % 10;
if(first <= second)
return 0;
temp = temp / 10;
}
return 1;
}
void ascending(int s, int e, int size)
{
int i =0;
for(i=s;i<=e;i++)
{
if(valid(i))
printf("%d\n",i);
}
}
int main()
{
int start = 1, end =1, i=0, size = 2;
for(i=1;i<size;i++)
start = start * 10;
end = start * 10 - 1;
ascending(start, end, size);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int security(int o, int n)
{
int temp_o, temp_n, flag = 0;
while(o > 0 && n > 0)
{
temp_o = o%10;
temp_n = n%10;
if(temp_o != temp_n)
{
if(((temp_o + 3 == temp_n)&&(temp_o + 3 < 10)) || ((temp_o - 3 == temp_n) && (temp_o - 3 > 0)) || ((temp_o +1 == temp_n)&&((temp_o + 1)%3!=1 )) || ((temp_o - 1 == temp_n)&&((temp_o-1)%3!=0)))
{
if(flag == 0)
flag =1;
else
return 0;
}
else
{
return 0;
}
}
o = o/10;
n = n/10;
}
if(n!=0 || o!=0)
return 0;
else
return 1;
}
int main()
{
int valid = security(1478, 1175);
if(valid)
printf("Authorized!!\n");
else
printf("Failed!!\n");
return 0;
}
Any comment pls
- kkkk October 17, 2014#include <stdio.h>
#include <stdlib.h>
char key[12][5] = {{},{},{'a','b','c','2',' '},{'d','e','f','3',' '},{'g','h','i','4',' '},{'j','k','l','5',' '},{'m','n','o','6',' '},{'p','q','r','s','7'},{'t','u','v','8',' '},{'w','x','y','z','9'},{' ',' ',' ',' ',' '},{}};
void sms(char* str)
{
int i=0,j=0,count =0;
char op[100] = {0};
while(str[i])
{
printf("%c %c %d\n",str[i],str[i+1],count);
if(str[i]==str[i+1])
{
count++;
}
else
{
if(str[i]=='#')
{
}
else if(str[i]=='*')
{
op[j] = ' ';
j++;
}
else
{
int idx = (int)str[i]-'0';
if(idx==7 || idx == 9)
{
op[j] = key[idx][count%5];
j++;
}
else if(idx!=0 && idx!=1)
{
op[j] = key[idx][count%4];
j++;
}
}
count = 0;
}
i++;
}
printf("output: %s\n",op);
}
int main()
{
char *s = "203";
sms(s);
return 0;
}
Can you please comment on this program ?
- kkkk October 16, 2014
Solve all the questions in careercup under EPIC. It is more than enough to crack the programming part and a little aptitude and brain teaser part.
- kkkk October 24, 2014All the best for your Exam!!