密码比对问题

 

 

 


三次密码输入
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
int main()
{
char arr[20] = { 0 };
int i;

for (i = 0; i < 3; i++)
{
printf("请输入密码:\n");
scanf("%s", arr);
if (strcmp(arr, "123456") == 0)
{
printf("密码正确!\n"); 
break;
}
else
{
printf("密码错误,请再输入一次!\n");
}
}
if (i == 3)
{
printf("退出系统\n");
}
else if (i < 3)
{
printf("登陆成功!\n");
}
system("pause");
return 0;
}










大小写字母输出相对的,数字不输出


#include<stdio.h>
#include<Windows.h>
int main()
{
char arr[100] = {0};
int i;
char j , enter;
printf("请输入键盘上字符:\n");
for (i = 0; i < 100; i++)
{
arr[i] = getchar();
enter = arr[i];
if (enter < 91 && enter > 64)
{
j = arr[i] + 32;
putchar(j);
putchar('\n');
continue;
}
else if (enter > 96 && enter < 123)
{
j = arr[i] - 32;
putchar(j);
putchar('\n');
continue;
}
else if (enter < 58 && enter >47)
{
j = NULL;
putchar(j);
putwchar('\n');
continue;
}
}
system("pause");
return 0;
}








计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
#include<stdio.h>
#include<Windows.h>
int main()
{
int i;
double value;
for (value = 0, i = 1; i < 101; i++)
{
if (i%2==1)
{
value += 1.0 / i;
}
else if (i % 2 == 0)
{
value -= 1.0 / i;
}
}
printf("VALUE = %lf", value);
system("pause");
return 0;
}






输出整数每一位
#include<stdio.h>
#include<Windows.h>
int main(void)
{
int n;
int a;
scanf("%d", &n);
while (n)
{
a = n % 10;
n /= 10;
printf("%d\n ", a);
}

system("pause");
return 0;
}






1到100之间9的次数
#include<stdio.h>
#include<Windows.h>
int main()
{
int i;
int count = 0;
for (i = 1; i < 101; i++)
{
if (i % 10 == 9)
{
count++;
}
else if (i / 10 == 9)
{
count++;
}

}
printf("%d\n", count);
system("pause");
return 0;
}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值