摘要: 1 #include<cstdio> 2 #include<cstring> 3 const int N = 10; 4 int a[N][N]; 5 int main(){ 6 int n,x,y,tot; 7 memset(a,0,sizeof(a)); 8 scanf("%d",&n);//n 阅读全文
posted @ 2020-03-08 22:28 xuecl 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using std::cout; 3 4 5 int func(char *s){ 6 if(s==NULL) return -1; 7 8 int num=0; 9 while(*s!='\0'){ 10 num = num*10 + *s - '0' 阅读全文
posted @ 2020-03-08 22:21 xuecl 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 3 int main(){ 4 5 char c1 = 'a'; 6 char c2 = 'b'; 7 8 const char *p = &c1; 9 // *p = 'b';//错 10 p = &c2;//对 11 // 结论:const cha 阅读全文
posted @ 2020-03-06 17:43 xuecl 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 4 typedef int elem; 5 6 struct Node{ 7 elem n; 8 struct Node * next; 9 }; 10 11 //创建 12 Node* Create_li 阅读全文
posted @ 2020-03-05 21:03 xuecl 阅读(418) 评论(0) 推荐(0) 编辑
摘要: 题意: 比如,输入:I come from China. 输出:China. from come I 思路:先将这个字符串整体倒置,再将单个单词倒置,这样既不需要移动元素,也不需要额外的辅助空间,还可以重用代码,很不错吧。 代码: 1 #include <iostream> 2 3 int len( 阅读全文
posted @ 2020-03-05 20:11 xuecl 阅读(773) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 /* 4 具体思路如下: 5 1.定义一个二维数组chessboard[8][8],用于保存黑白双方棋子的位置。如果数组元素为0,表示该单元格未落子;如果是-1,表示该单元格是黑子;如果是1,则表示该单元格是白 阅读全文
posted @ 2020-02-26 12:37 xuecl 阅读(1897) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <bitset> 3 using namespace std; 4 int main() 5 { 6 int n,m; 7 int len; 8 string temp; 9 bitset<8> t; 10 while(cin>>n> 阅读全文
posted @ 2020-02-25 17:54 xuecl 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int MAX = 100; 5 char arr[MAX][MAX];//存放 “w 和 . ” 6 7 int nx[4] = {0,1,0,-1};//4个坐标(0,1)(1 阅读全文
posted @ 2020-02-25 17:26 xuecl 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int MAX = 100; 5 char arr[MAX][MAX]; 6 int n,m; 7 8 void init(); 9 void solve(); 10 void d 阅读全文
posted @ 2020-02-25 17:13 xuecl 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 4 bool isprime(int a){ 5 6 if(a<=1) return false; 7 8 for(int i=2;i*i<=a;i++){ 9 if(a%i==0) return fals 阅读全文
posted @ 2020-02-23 19:32 xuecl 阅读(145) 评论(0) 推荐(0) 编辑