第五次
来源:互联网 发布:刺客信条4a卡优化 编辑:程序博客网 时间:2024/04/29 11:37
1.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void menu()
{
printf("**********************\n");
printf("***1.play 0.exit ***\n");
}
void game()
{
int num = 0;
int input = 0;
num = rand() % 100 + 1;
while (1)
{
#include<stdlib.h>
#include<time.h>
void menu()
{
printf("**********************\n");
printf("***1.play 0.exit ***\n");
}
void game()
{
int num = 0;
int input = 0;
num = rand() % 100 + 1;
while (1)
{
printf("请猜数字;>");
scanf_s("%d", &input);
if (input > num)
{
printf("猜大了\n");
}
else if (input < num)
{
printf("猜小了\n");
}
else
{
printf("猜对了\n");
break;
}
}
}
int main()
{
int input = 0;
srand((unsigned int)time(NULL));
do
{
menu();
printf("请选择;>");
scanf_s("%d",&input);
switch (input)
{
case 1:
game();
break;
case 0:
printf("退出游戏\n");
break;
default:
printf("选择错误\n");
break;
}
}
while (input);
system("pause");
return 0;
}
scanf_s("%d", &input);
if (input > num)
{
printf("猜大了\n");
}
else if (input < num)
{
printf("猜小了\n");
}
else
{
printf("猜对了\n");
break;
}
}
}
int main()
{
int input = 0;
srand((unsigned int)time(NULL));
do
{
menu();
printf("请选择;>");
scanf_s("%d",&input);
switch (input)
{
case 1:
game();
break;
case 0:
printf("退出游戏\n");
break;
default:
printf("选择错误\n");
break;
}
}
while (input);
system("pause");
return 0;
}
2.
#include<stdio.h>
#include<Windows.h>
int main()
{
int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int mid = 0;
int left = 0;
int right = sizeof arr / sizeof arr[0] - 1;
int key = 7;
while (left <= right)
{
mid = left + (right - left) / 2;
if (arr[mid] < key)
{
left = mid + 1;
}
else if (arr[mid]>key)
{
right = mid - 1;
}
else
{
printf("找到了:%d\n", mid);
break;
}
}
if (left > right)
#include<Windows.h>
int main()
{
int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int mid = 0;
int left = 0;
int right = sizeof arr / sizeof arr[0] - 1;
int key = 7;
while (left <= right)
{
mid = left + (right - left) / 2;
if (arr[mid] < key)
{
left = mid + 1;
}
else if (arr[mid]>key)
{
right = mid - 1;
}
else
{
printf("找到了:%d\n", mid);
break;
}
}
if (left > right)
printf("-1\n");
system("pause");
return 0;
}
system("pause");
return 0;
}
3.
#include<stdio.h>
#include<windows.h>
#include<math.h>
int main()
{
int i = 0;
char arr2[10]={0};
#include<windows.h>
#include<math.h>
int main()
{
int i = 0;
char arr2[10]={0};
for (i = 0; i < 3; i++)
{
printf("请输入密码:");
scanf_s("%s",arr2);
if (0 == strcmp(arr2, "123456"))
{
break;
}
else
{
printf("输入错误,请重新输入\n");
}
}
if (i==3)
printf("登陆失败\n");
else
printf("登陆成功\n");
system("pause");
return 0;
}
4.
#include<stdio.h>
//#include<string.h>
//#include<string.h>
int main()
{
{
int ch = 0;
while ((ch=getchar())!=EOF)
if (ch >='A'&&ch <='Z')
{
putchar(ch + 32);
}
else if (ch >= 'a'&&ch <= 'z')
{
while ((ch=getchar())!=EOF)
if (ch >='A'&&ch <='Z')
{
putchar(ch + 32);
}
else if (ch >= 'a'&&ch <= 'z')
{
printf("%c", ch - 32);
}
system("pause");
return 0;
}
}
system("pause");
return 0;
}
阅读全文
0 0
- 第五次
- 第五次
- 第五次培训
- 第五次作业
- 第五次作业
- 第五次作业
- 第五次作业
- 第五次作业
- 第五次作业
- 第五次作业
- 第五次上机
- 第五次编程题
- 第五次作业
- 第五次课后作业
- 第五次课后作业
- 第五次作业
- 第五次作业
- 第五次课堂作业
- mysql root忘记密码重置
- 高数 03.05函数的极值与最大值最小值
- 使用 EasyUI 实现 MySQL 数据 简单的 增删改查
- 关于mysql的一些操作指令基础1-1
- 安卓布局 Recycleview
- 第五次
- 线序
- Jenkins代码审查功能的实现方案
- js 多个radio 默认选中
- C语言自定义类型总结
- 架构师之路:JavaEE系统架构师学习路线
- 笔记(五)
- B. Wrath (思路题目)
- 多线程编程之pthread_create函数应用