2022.3.26

//  2022.3.26
//数组:
//      相同数据类型的有序连续存储,
//    int arr [ 10 ]   ={1,2,23,4,5,6,10,7,8,9};
//    各个元素的内存地址,连续。
//   数组名为地址,是数组首元素的地址, arr == &arr[0];
//   printf("数组大小:%u\n", sizeof(arr[0]);
//   printf("数组元素的大小:%u\n", sizeof(arr[0]);
//   printf("数组元素个数:%d\n", sizeof(arr) / sizeof(arr[0]);
//   数据的第一个元素下标:0
//二维数组:
//int arr[10] = { 1,2,3,5,6,7 };
//{1, 2, 3, 5, 6, 7};
//{1, 2, 3, 5, 6, 7};
//{1, 2, 3, 5, 6, 7};
//{1, 2, 3, 5, 6, 7};
//{1, 2, 3, 5, 6, 7};
//
//定义语法:
//int[2][3] =
//{
//    {2, 5, 8},
//    {7, 9, 10}
//};
//int arr[3][5] = {(2,3,54,56,7)},(2,67,4,35,9),(1,4,16,3,78)}
//
//打印:for(i = 0; i < 3; i++)     //行
//{
//    for (j = 0; j < 5; j++)
//    {
//        printf("%d ", arr[i][j]);
//    }
//    printf("\n");
//}
//
//大小:
//    数组大小: sizeof(arr);
//    一行大小: sizeof(arr) / sizeof(arr[0]) 
//     一个元素大小:sizeof(arr[0][0])  单位:字节
//           行数: row =  sizeof(arr) / sizeof(arr[0])
//           例数: col =  sizeof(arr[0] / sizeof(arr[0][0])
//
//地址合一:
//        printf("%p\n", arr); == printf("%p\n", &arr[0][0]); == printf("%p\n", arr[0]);
//        数组的首地址 == 数组的首元素地址 == 数组的首行地址。
//二维数组的初始化
//    (1) 常规初始化:
//        int arr[3][5] = {{2, 3, 54, 56, 7 },{2, 67, 4, 35, 9 },{1, 4, 16, 3, 78} };
//     (2)  不完全初始化:
//       int arr[3][5] = {{2, 3},{2, 67, 4, },{1, 4, 16, 78 }};未被初始化的数值为 0;
//        int arr[10] = { 0 }; 初始化一个 初值全为0的二维数组
//        int arr [3][5] = {{2, 3, {2, 67, 4, },{1, 4, 16, 78} };【少见】系统自动分配行列,
//     (3) int arr [][] = {1, 3, 4, 6, 7}; 二维数组定义必须指定列值,
//           int arr[][2] = {1, 3, 4, 6, 7}; //可以不指定行值。
//
//练习:求出5名学生3门功课的总成绩。(一个学生的总成绩,一门功课的总成绩)
//     for (size_t i = 0; i < row; j++)
//       {
//             for (size_t j = 0; j < col; j++)
//                 {
//                      scanf("%d", &scores[i][j]);
//                 }
//       }
// //   求一个学生的总成绩
//      for (size_t i = 0; i < row; i++) //  每个学
//      {
//             int sum = 0;
//             for (size_t j = 0; j < col; j++) // 每个学生的成绩
//              {
//                sum += scores[i][j];
//              }
//              printf("第%d个学生的总成绩为: %d\n", i+1, sum);
//      }
//   求一门功课的总成绩
//   for (size_t i = 0; i < col; i++)   //  第几门功课
//    {
//       int sum = 0;  
//         for (size_t j = 0; j < row; j++) //  每门功课的第几个学生
//           {
//             sum += scores[i][j];
//           }
//        printf("第%d门功课的总成绩为: %d\n",i + 1, sum);
//   }
//              
//  
// 快捷导入代码:
//    VS -- 》 工具 -- 》 代码片段管理器 -- 》 Visual C++
//多维数组;【了解】
//     三维数组:[层】[行][列]
//     数组类型:数组名[层][行][列]
//   int arr[2][3][4];
// { {12, 3, 4, 5}
//   {12, 3, 4, 5} },
// { {12, 3, 4, 5}
//   {12, 3, 4, 5} },
// { {12, 3, 4, 5}
//   {12, 3, 4, 5} },
//   for(i = 0; i < 3; i++)   层
//      for (j = 0; j < 3; j++) 行
//        for (k = 0; k < 4; k++) 列
//          printf("%d", arr[i][j][k]);
//   
//  4维、5维、6维、....n维。
//
//    int arr[10];
//    short arr[20];
//    long long arr[20];
// 
//字符数组 和 字符串区别:
//     字符数组:
//            char str[10] = {'h','e','l','l','o'};0 就是\0
// 
//    
//     字符串:
//         char str[10] = {'h','e','l','l','o','\0'};
//         char str[] = "hello";
//         printf("%s"); 使用printf打印字符串的时候,必须碰到 \0 结束。
//    练习:键盘输入字符串,存至str[]中,统计每个字母出现的次数。

//  字符串获取 scanf:
//    注意:  (1) 用于存储字符串的空间必须足够大,防止溢出, char str[5];
//             (2) 获取字符串,%s, 遇到 空格 和 \n 终止。
//    借助“正则表达式”获取带有空格的字符串: scanf("%[^\n]",str);  //[意思数除空格之外]
// 
//    字符串操作函数:
//           gets:
//             
//          fgets:
// 
//        puts:  
// //
// //
//


//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h>
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//
//int main(void)
//{
//  
//     int arr[4][3] = {  {2, 7, 8},
//                       {75,  8,  9},
//                       {26,  37,  99},
//                        {22,  55, 88} };
//    for (size_t i = 0; i < 4; i++)    //行
//    {
//        for (size_t j = 0; j < 3; j++)  //列
//        {
//            printf("%d ", arr[i][j]);
//        }
//        printf("\n");
//    }
//    printf("数组的大小为:%u\n", sizeof(arr));
//    printf("数组行的大小为: %u\n", sizeof(arr[0]));
//    printf("数租一个元素大小: %u\n", sizeof(arr[0][0]));
//
//    printf("行数=总大小/一行大小: %d\n", sizeof(arr) / sizeof(arr[0]));
//    printf("列数=行大小/一个元素大小: %d\n", sizeof(arr[0]) / sizeof(arr[0][0]));
//
//    printf("arr = %p\n", arr);
//    printf("&arr[0] = %p\n", &arr[0][0]);
//    system("panse");
//    return EXIT_SUCCESS;
//}
//
//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h>
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//
//    int arr[4][3] = { 0 };
//    for (size_t i = 0; i < 4; i++)    //行
//    {
//        for (size_t j = 0; j < 3; j++)  //列
//        {
//            printf("%d ", arr[i][j]);
//        }
//        printf("\n");
//    }
//    printf("数组的大小为:%u\n", sizeof(arr));
//    printf("数组行的大小为: %u\n", sizeof(arr[0]));
//    printf("数租一个元素大小: %u\n", sizeof(arr[0][0]));
//
//    printf("行数=总大小/一行大小: %d\n", sizeof(arr) / sizeof(arr[0]));
//    printf("列数=行大小/一个元素大小: %d\n", sizeof(arr[0]) / sizeof(arr[0][0]));
//
//    printf("arr = %p\n", arr);
//    printf("&arr[0] = %p\n", &arr[0][0]);
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h>
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//
//    int arr[][2] = { 1, 3, 4, 6, 7 };
//
//    int row = sizeof(arr) / sizeof(arr[0]);
//    int col = sizeof(arr[0]) / sizeof(arr[0][0]);
//    for (size_t i = 0; i < 4; i++)    //行
//    {
//        for (size_t j = 0; j < 3; j++)  //列
//        {
//            printf("%d ", arr[i][j]);
//        }
//        printf("\n");
//    }
//    printf("数组的大小为:%u\n", sizeof(arr));
//    printf("数组行的大小为: %u\n", sizeof(arr[0]));
//    printf("数租一个元素大小: %u\n", sizeof(arr[0][0]));
//
//    printf("行数=总大小/一行大小: %d\n", sizeof(arr) / sizeof(arr[0]));
//    printf("列数=行大小/一个元素大小: %d\n", sizeof(arr[0]) / sizeof(arr[0][0]));
//
//    printf("arr = %p\n", arr);
//    printf("&arr[0] = %p\n", &arr[0][0]);
//    system("panse");
//    return EXIT_SUCCESS;
//}
//----------------------------------------------下面的程序不对以后在看
//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h>
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    int scores[5][3];
//
//    int row = sizeof(scores) / sizeof(scores[0]);
//    int col = sizeof(scores[0]) / scores[0][0]);
//
//    for (size_t i = 0; i < row; i++)
//    {
//        for (size_t j = 0; j < col; j++)
//        {
//            scanf("%d", &scores[i][j]);
//        }    
//    }
//    //  打印5 名学生、3门功课成绩
//    for (size_t i = 0; i < row; i++)
//    {
//        for (size_t j = 0; j < col; j++)
//        {
//            printf("%d ",scores[i][j]);
//        }
//        printf("\n");
//    }
//    //  求一个学生的总成绩
//    for (size_t i = 0; i < row; i++) //每个学生
//    {
//        int sum = 0;
//        for (size_t j = 0; j < col; j++) //每个学生的成绩
//        {
//            sum += scores[i][j];
//        }
//        printf("第%d个学生的总成绩为:%d\n", i + 1, sum);
//    }
//    system("panse");
//    return EXIT_SUCCESS;
//}
//----------------------------------------------下面的程序不对以后在看
//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    int scores[5][3];
//
//    int row = sizeof(scores) / sizeof(scores[0]);
//    int col = sizeof(scores[0]) / scores[0][0]);
//
//    for (size_t i = 0; i < row; i++)
//    {
//        for (size_t j = 0; j < col; j++)
//        {
//            scanf("%d", &scores[i][j]);
//        }
//    }
//    //  打印5 名学生、3门功课成绩
//    for (size_t i = 0; i < row; i++)
//    {
//        for (size_t j = 0; j < col; j++)
//        {
//            printf("%d ", scores[i][j]);
//        }
//        printf("\n");
//    }
//    
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    int a[3][4][2] = {
//        {
//            { 1, 2},
//            { 2, 3},
//            { 4, 5},
//            { 5, 6},
//        },
//        {
//        {45, 67},
//        { 78, 90},
//        { 12, 6},
//        { 45, 9},
//        },
//        {
//            { 45, 67},
//            { 78, 90},
//            {12, 6},
//            { 45, 9},
//        },
//    };
//    //  int arr[2][3][5] = {1, 2, 4, 5, 6, 7, 8, 9, 0, 0, 7, 9, 8};
//    for (size_t i = 0; i < 3; i++)
//    {
//        for (size_t j = 0; j < 4; j++)
//        {
//            for (size_t k = 0; k < 2; k++)
//            {
//                printf("%d ", a[i][j][k]);
//            }
//            printf("\n");
//        }
//        printf("\n\n");
//        }
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[6] = { 'h','e','l','l','o','\0'};
//
//    printf("%s\n", str);
//
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[5] = { 'h','e','l','l','o' };
//
//    printf("%s\n", str);
//
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[5] = { 'h','e','l','l','o' };
//
//    char str2[] = "world"; // == {'w','o','r','l','d','\0'}
//
//    printf("%s\n", str2);
//
//    system("panse");
//    return EXIT_SUCCESS;
//}

// 统计每个字符出现的次数。
//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[100] = { 0 };
//
//    scanf("%s", str);
//
//    printf("str = %s\n", str);
//
//    system("panse");
//    return EXIT_SUCCESS;
//}


// 统计每个字符出现的次数。

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[11] = { 0 };     //  helloworld
//
//    for (size_t i = 0; i < 10; i++)
//    {
//        scanf("%c", &str[i]);
//    }
//    printf("str = %s\n", str);
//
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[11] = { 0 };     //  helloworld
//
//    for (size_t i = 0; i < 10; i++)
//    {
//        scanf("%c", &str[i]);
//    }
//    for (size_t i = 0; i < 10; i++)
//    {
//        printf("%c", str[i]);
//    }
//   
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[11] = { 0 };     //  helloworld == > 26个英文字母 a=z  a:97  d:100
//
//    // scanf("%s",str);
//    for (size_t i = 0; i < 10; i++)
//    {
//        scanf("%c", &str[i]);
//    }
//
//    //int count[26] = { 0 }; // 代表26个英文字母出现的次数,
//    
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[11] = { 0 };     //  helloworld == > 26个英文字母 a=z  a:97  d:100
//
//    // scanf("%s",str);
//    for (size_t i = 0; i < 10; i++)
//    {
//        scanf("%c", &str[i]);
//    }
//
//   int count[26] = { 0 }; // 代表26个英文字母出现的次数,
//
//   for (size_t i = 0; i < 11; i++)
//   {
//     int index = str[i] - 'a';  //用户输入的字符在 count 数组中的下标值。
//     count[index]++;
//   }
//   for (size_t i = 0; i < 26; i++)
//   {
//       if (count[i] != 0)
//       {
//           printf("%c 字符在字符串中出现 %d 次\n", i + 'a', count[i]);
//       }
//   }
//
//    system("panse");
//    return EXIT_SUCCESS;
//}

//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//#include <string.h> 
//#include <stdlib.h>
//#include <math.h>
//#include <time.h>
//
//int main(void)
//{
//    char str[10];
//
//    scanf("%s", str);
//
//    printf("%s\n", str);
//
//    system("panse");
//    return EXIT_SUCCESS;
//}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h> 
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(void)
{
    char str[100];

    scanf("%[^\n]s", str);

    printf("%s\n", str);

    system("panse");
    return EXIT_SUCCESS;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值