20240125
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
int main()
{
int A[7] = { 12,23,34,45,56,67,78 };
int B[7] = { 11,2,3,4,5,6,7 };
for (int i = 0; i < 7; i++)
{
int tmp = A[i];
A[i] = B[i];
B[i] = tmp;
}
for (int i = 0; i < 7; i++)
{
printf("%d ",A[i]);
}
printf("\n");
for (int i = 0; i < 7; i++)
{
printf("%d ", B[i]);
}
printf("\n");
return 0;
}
int main20() {
int arr[10] = { 0 };
for (int i = 0; i < 10; i++)
{
scanf("%d", &arr[i]);
}
int sum = 0;
/*for (int i = 9; i >= 0; i--)
{
printf("%d ", arr[i]);
}*/
return 0;
}
int main19() {
int n, m;//2 3 2行3列
while (scanf("%d %d", &n, &m) != EOF) { // 注意 while 处理多个 case
// 64 位输出请用 printf("%lld") to
int arr[n][m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
scanf("%d", &arr[i][j]);
}
}
//已经有数据了
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
printf("%d ", arr[j][i]);
}
printf("\n");
}
}
return 0;
}
int main18() {
int n;
while (scanf("%d", &n) != EOF) { // 注意 while 处理多个 case
64 位输出请用 printf("%lld") to
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (i == 0 || i == n - 1)
{
printf("* ");
}
else if (j == 0 || j == n - 1)
{
printf("* ");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
return 0;
}
int main17()
{
int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
printf("%d %d",&arr[0],&arr[1]);
printf("%p %p",&arr[0],arr);
是 使用字符串给数组赋值 最终的结果 是一个字符数组 acX: [a,b,c,d,e,f,g,\0]
char acX[] = "abcdefg";
就是一个没有\0的 字符数组 acY: [a,b,c,d,e,f,g]
char acY[] = { 'a','b','c','d','e','f','g' };
int arr[] = { 1,2,(3,4),5 };// 1 2 4 5
printf("%d\n", sizeof(arr));
return 0;
}
int main16()
{
int a = 18;
int b = 24;
int c = a % b;//6
while (c != 0)
{
a = b;
b = c;
c = a % b;
}
printf("%d\n",b);
return 0;
}
int main15()
{
double sum = 0;
int flg = 1;
for (int i = 1; i <= 100; i++)
{
sum = sum + 1.0 / i * flg;//1/2 1/3 1/4
flg = -flg;//-1
}
printf("%lf\n",sum);
return 0;
}
int main14()
{
int arr[10] = {10,6,2,19,3,6,1,8,7,17};
假设第一个人 最厉害
int max = arr[0];
从第2个人开始比较
for (int i = 1; i < 10; i++)
{
if (max < arr[i])
{
max = arr[i];
}
}
printf("max = %d\n", max);
return 0;
}
int main13()
{
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
printf("%d*%d=%2d ",j,i,i*j);
}
printf("\n");
}
return 0;
}
int main12()
{
int count = 0;
for (int i = 1; i <= 100; i++)
{
99
if (i % 10 == 9)
{
count++;
}
加上else 就代表 有多少个数字 包含9
else if (i / 10 == 9)
{
count++;
}
}
printf("%d\n",count);
return 0;
}
int main11()
{
int a, b, c;
while (scanf("%d %d %d", &a, &b, &c) != EOF)
{
if ((a + b) > c && (a + c) > b && (b + c) > a)
{
1、判断是不是等边三角形
if (a == b && b == c)
{
printf("Equilateral triangle!\n");
}
2、判断是不是等腰三角形
else if ((a == b) && (b != c) || (a == c) && (c != b) || (b == c) && (c != a))
{
printf("Isosceles triangle!\n");
}
else
{
printf("Ordinary triangle!\n");
}
}
else
{
printf("Not a triangle!\n");
}
}
return 0;
}
int main10()
{
char* str1 = "abcd";
str1 > str2 正数
int ret = strcmp("abcd","abce");
if (ret > 0)
{
printf("str1 > str2");
}
else if (ret < 0)
{
printf("str1 < str2");
}
else
{
printf("str1 = str2");
}
return 0;
}
int main9()
{
int a = 10;
if (a == 3)
{
if (a == 10)
{
}
else
{
printf("dsfsa");
}
}
return 0;
}
int main8()
{
int a, b, c;
scanf("%d%d%d",&a,&b,&c);
if(a < b)
{
int tmp = a;
a = b;
b = tmp;
}
if (a < c)
{
int tmp = a;
a = c;
c = tmp;
}
if (b < c)
{
int tmp = b;
b = c;
c = tmp;
}
printf("%d,%d,%d",a,b,c);
return 0;
}
int main7()
{
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0)
{
printf("%d ",i);
}
}
return 0;
}
int main6()
{
int i = 0;
for (i = 0; i < 10; i++)
{
if (i = 5)
printf("%d ", i);
}
return 0;
}
int main5()
{
int a;//5
while (scanf("%d", &a) != EOF)
{ // 注意 while 处理多个 case
64 位输出请用 printf("%lld") to
for (int i = 0; i < a; i++)
{
printf("*");
}
printf("\n");
}
return 0;
}
int main4() {
int a, b;
while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case
64 位输出请用 printf("%lld") to
if (a > b) {
printf("%d>%d\n", a, b);
}
else if (a == b) {
printf("%d=%d\n", a, b);
}
else {
printf("%d<%d\n", a, b);
}
}
return 0;
}
int main3() {
int a;
while (scanf("%d", &a) != EOF) { // 注意 while 处理多个 case
64 位输出请用 printf("%lld") to
if (a >= 140) {
printf("Genius\n");
}
}
return 0;
}
int main2()
{
char buff[20] = { 0 };
scanf("%s",buff);
gets(buff);//读取一个字符串的
printf("%s\n",buff);
return 0;
}
int main1()
{
int a, b, c;
a = 5;
c=6 a=6
c = ++a;
++c -> 7
b = 7
c++ -> c=8
++a -> a=7
a++ -> a=8
b = (++c, c++, ++a, a++);// b = a++;
printf("b = %d \n:", b);
printf("a = %d \n:", a);
b = b + (a++ + c) // (a++ + c) == a + c 、 a++
b = 7 + (8+8) -> 23
a = 9
/*
b += a++ + c;
printf("a = %d b = %d c = %d\n:", a, b, c);
*/
return 0;
}