作业介绍

1.13 排序与查找&文件重定向

#include<iostream>
#include<cstring> // c语言 string.h
#include<string> // c++ 
using namespace std;
const int N=110;
char str[N]; // 定义字符数组 

int main(){
//    cin>>str; // 以空格,制表符,回车作为分割 
//    cout<<str<<endl;
    int n = strlen(str); // 求字符数组长度
    cout<<n<<endl; 
  
    char str1[] = "123", str2[] = "456";
    strcat(str1, str2);  // 将 str2连接到 str1后面
    cout<<str1<<endl;// str1 = "123456", str2="456" 
   
    strcpy(str1, str2);// 将 str2复制给 str1
    cout<<str1<<endl;// str1="456" , str2="456" 
  
    strcpy(str1, "123");
    int x = strcmp(str1, str2); // 比较 str1 和 str2的大小:str1 - str2
    cout<<x<<endl;
    return 0;
}

二维数组

#include<iostream>
using namespace std;
const int N=1e3+10;
//int dp[N];
int dp[N][N]; // N*N <= 1e8
int b[3][4]; // 全局变量,默认 0 

int main(){
	int a[3][4]; // 局部变量,随机值 
	int c[3][4] = { {1,2,3,4}, {4,5,6,7}, {7,8,9,0} }; // 局部变量,初始化赋值 
	int d[3][4] = { {1,2}, {4,7}, {7,8} }; // 局部变量,初始化赋值,未赋值部分为 0 
	int e[3][4] = { {1,2}, {4,7} }; // 局部变量,初始化赋值,未赋值部分为 0  
	int f[3][4] = { 1,2,3,4,5,6,7,8 }; // 局部变量,初始化赋值,未赋值部分为 0 

//	a[0][0]  a[0][1]  a[0][2]  a[0][3] 
//	a[1][0]  a[1][1]  a[1][2]  a[1][3] 
//	a[2][0]  a[2][1]  a[2][2]  a[2][3] 

	for(int i=0; i<3; i++){// 第 i 行
		for(int j=0; j<4; j++){ // 第 j 列
			cout<<f[i][j]<<" "; 
		} 
		cout<<endl;
	}
	return 0;
}
状态
已结束
题目
26
开始时间
2024-3-23 0:00
截止时间
2024-4-30 23:59
可延期
24 小时