#define _CRT_SECURE_NO_WARNINGS 1
#include <string.h>
#include <stdio.h>
int main()
{
int arr1[10] = {1,2,3};//不完全初始化
char arr2[5] = { 1, 2, 3, 4, 5 };
char arr3[] = { 1, 2, 3, 4};
char arr4[5] = { 1, 2, 3};
char arr5[3] = { 'a', 4, 'c' };
char arr6[] = { 'a', 'b', 'c'};
char arr7[] = "abcdef";
return 0;
}
int main()
{
char arr[] = "abcdef";//{ 'a', 'b', 'c', 'd', 'e', 'f' };
int i = 0;
for (i = 0; i<strlen(arr); i++)
{
printf("%c ", arr[i]);
}
return 0;
}
输入一串随机数组,进行打印
int main()
{
char arr[20] = {0};//"abcdef";//{ 'a', 'b', 'c', 'd', 'e', 'f' };
scanf("%s", &arr);
int i = 0;
for (i = 0; i<strlen(arr); i++)
{
printf("%c ", arr[i]);
}
return 0;
}
BUG修改完毕, 账号登录系统1.0
#define _CRT_SECURE_NO_WARNINGS 1
#include <string.h>
#include <stdio.h>
int main()
{
char accounts[40] = { 0 };
char password[40] = { 0 };
int i = 0;
printf("请输入账号:>");
scanf("%s", &accounts);
if (strcmp(accounts, "123456")==0)// && strcmp(accounts, "123") == 0 && strcmp(accounts, "456") == 0)
{
printf("登记库中存在\n");
}
for (i = 1; i <= 3; i++)
{
printf("请输入密码:>");
scanf("%s", &password);
if ((strcmp(password, "YG123456") == 0) && (strcmp(accounts, "123456") == 0))//==不能用来比较两个字符串是否相等,应该使用一个库函数-strcmp
{
printf("登陆成功\n");
break;
}
else
{
printf("账号不在登记库中,不予登录\n");
printf("请输入账号:>");
scanf("%s", &accounts);
}
if (i == 3)
{
printf("三次均错误,账号已冻结\n");
}
}
return 0;
}
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sz = sizeof(arr) / sizeof(arr[0]);
int i = 0;
for (i = 1; i < sz; i++)
{
printf("arr[%d] = %p\n", i, &arr[i]);
}
return 0;
}
int main()
{
int arr[3][4] = {{1,2,3}, {4,5}};
int i = 0;
for (i = 0; i < 3; i++)
{
int j = 0;
for (j = 0; j < 4; j++)
{
printf("&arr[%d][%d] = %p\n", i, j, &arr[i][j]);
}
}
return 0;
}
void bubble_sort(int arr[], int se)
{
int i = 0;
for (i = 0; i < se - 1; i++)
{
int flag = 1;
int j = 0;
for (j = 0; j<se - 1 - i; j++)
{
if (arr[j] > arr[j + 1])
{
int tmp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = tmp;
flag = 0;
}
}
if (flag == 1)
{
break;
}
}
}
int main()
{
int arr[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
int i = 0;
int se = sizeof(arr) / sizeof(arr[0]);
bubble_sort(arr, se);
for (i = 0; i < se; i++)
{
printf("%d ", arr[i]);
}
return 0;
}
标签:13,main,所学,int,arr,char,accounts,printf,分享
From: https://blog.51cto.com/u_16182079/6716267