
c++算法
文章平均质量分 59
cwzhsi
这个作者很懒,什么都没留下…
展开
-
54. Spiral Matrix
54. Spiral MatrixMy SubmissionsQuestionTotal Accepted: 52570 Total Submissions: 238571 Difficulty: MediumGiven a matrix of m x n elements (m rows, n columns), return all elemen原创 2016-02-26 08:57:01 · 564 阅读 · 0 评论 -
1065. A+B and C (64bit) (20)
我写的时候其实有测试点没同过,参考别人的,呜呜。这里重要的是long long数据类型范围,这里我在网上搜索了下其他的各种类型的范围:int 、long 、long long数据类型范围unsigned int 0~4294967295 int 2147483648~2147483647 unsigned long 0~4294967295long原创 2014-11-26 10:28:03 · 658 阅读 · 0 评论 -
1067. Sort with Swap(0,*) (25)
下面是自己写的,但是只得了19分,有两个点超时#includeusing namespace std;//这样写会超时 void swap(int *x,int *y) {int temp; temp=*x; *x=*y; *y=temp; } int find(int *arr,int begin,int end) {f原创 2014-11-09 22:42:01 · 658 阅读 · 0 评论 -
1072. Gas Station (30)
#include#include#include#include#include#define INF 0x7ffffff#define NUM 1000+10+2using namespace std; int n,m,k,ds;int map[NUM][NUM]={0};int visited[NUM];int dist[NUM];原创 2014-11-04 20:15:41 · 517 阅读 · 0 评论 -
Dijkstra单元最短路径算法
#include#includeusing namespace std;#define MAX 999999#define M 100#define N 100typedef struct node{ int matrix[M][N]; int n; //定点数 int v; //边数}Graph;原创 2014-11-03 19:27:32 · 645 阅读 · 0 评论 -
pat 1070Mooncake (25)
#include#include#includeusing namespace std;struct moon{double amounts;double price;double value;}mooncake[1005];bool cmp(const struct moon &a,const struct moon &b)//注意这里的写原创 2014-10-21 14:34:11 · 495 阅读 · 0 评论 -
1076. Forwards on Weibo (30)
所有的测试点通过,除了最后一个运行超时#includeusing namespace std;#define max 10005int map[max][max];int visited[max];int level[max];int n,l;//用户数和深度void dfs(int id){visited[id]=1;for(int i=1;i原创 2014-10-16 16:03:32 · 806 阅读 · 0 评论 -
1075. PAT Judge (25)
#include#include#includeusing namespace std;#define MAX 10005struct student{int id;int score[7];int solved;int sum;bool flag;}stu[MAX];int score[7];bool cmp(const struct st原创 2014-10-15 08:40:37 · 744 阅读 · 0 评论 -
Pat 1073 PAT 1073. Scientific Notation (20)
#include#include#include#includeusing namespace std;int main(){string str,temp="";getline(cin,str);if(str[0]=='-'){temp+=str[0];}int indexE=str.find("E");string num=s原创 2014-10-10 11:03:56 · 785 阅读 · 0 评论