#include <stdio.h>
int main() {
long long n;
int num=3;
int count=0;
printf("Enter an integer: ");
scanf("%lld", &n);
if(n>9999999)
{
num=4;
}
printf("Number of cipher: %d", num);
// iterate at least once, then until n becomes 0
// remove last digit from n in each iteration
// increase count by 1 in each iteration
do {
n /= 10;
count++;
} while (count!=num);
if(count==3)
{
n/=10;
}
printf("Number of cipher: %lld", n);
}
you can make use do while loop. I believe cipher codified only on 7 and 8. If you still continue you can keep adding the code. As far as I understood, i tried to put into code here,
#include <stdio.h>
int main() {
long long n;
int num=3;
int count=0;
printf("Enter an integer: ");
scanf("%lld", &n);
if(n>9999999)
{
num=4;
}
printf("Number of cipher: %d", num);
// iterate at least once, then until n becomes 0
// remove last digit from n in each iteration
// increase count by 1 in each iteration
do {
n /= 10;
count++;
} while (count!=num);
if(count==3)
{
n/=10;
}
printf("Number of cipher: %lld", n);
}
发布评论
评论(1)
您可以在循环时使用DO。我相信密码仅在7和8上进行编码。如果您仍然继续进行,则可以继续添加代码。据我所知,我试图在此处进行代码,
you can make use do while loop. I believe cipher codified only on 7 and 8. If you still continue you can keep adding the code. As far as I understood, i tried to put into code here,