The problem of resource allocation for sudden tasks in crowd sensing has been studied.Firstly,the characteristics of sudden tasks are analyzed and a multi-period stochastic programming model with uncertain demand for sudden tasks is estab-lished.Three indicators are used to measure the allocation of resources,which are efficiency,effectiveness and fairness.A nonlin-ear optimization problem for minimizing cost is proposed.Then,aiming at the optimization problem,a resource allocation method based on Q learning algorithm has put forward and compare with dynamic programming algorithm and heuristic algorithm.Experi-mental results show that Q learning algorithm is better than heuristic algorithm in accuracy and dynamic programming algorithm in computing speed.