Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
3-4.c 914 Bytes
Copy Edit Raw Blame History
王振宇 authored 2022-03-04 21:42 . homework
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
//void RotateStr(char* str, int n)
//{
// char *p = str;
// char tmp;
// for (; n > 0; n--)
// {
// while (*(str + 1))
// {
// tmp = *str;
// *str = *(str + 1);
// *(str + 1) = tmp;
// str++;
// }
// str = p;
// }
//}
//int main()
//{
// int n = 0;
// char ch[] = "ABCD";
// scanf("%d", &n);
// RotateStr(ch, n);
// printf("%s", ch);
// return 0;
//}
int SearchNumber(int(*arr)[5], int x, int y, int n, int sz)
{
int i = 0;
int j = 0;
for (i = 0; i < x; i++)
{
for (j = 0; j < y; j++)
{
if (*(*(arr + i) + j) == n)
return 1;
}
}
return 0;
}
int main()
{
int n = 0;
int arr[5][5] = { {1, 2, 3, 4, 5},{2, 3, 4, 5, 6},{3, 4, 5, 6, 7},{4, 5, 6, 7, 8},{5, 6, 7, 8, 9} };
int sz = sizeof(arr) / sizeof(arr[0][0]);
scanf("%d", &n);
if (SearchNumber(&arr, 5, 5, n, sz) == 1)
printf("");
else
printf("");
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化