Cognitive radio networks (CRNs), offering novel network architecture for utilizing spectrum, have attracted significant attention in recent years. In CRNs, secondary users (SUs) first determine the status of a channel; if it is free, they start transmitting. If the status determination is wrong, SUs may unnecessarily interfere with the licensed primary user (PU). In cooperative spectrum sensing, a SU makes a decision about the presence of the PU based on its own and other SUs' sensing results. Malicious SUs (MSUs) send false sensing results to SUs so that they make wrong decisions about the PU presence. As a result, a SU may transmit during the presence of the PU or may keep starving for the spectrum. In this paper, we propose a reputation-based mechanism for cooperative spectrum sensing which can minimize the effects of MSUs on decision making. Some of the SUs are selected as distributed fusion centers (DFCs), which are responsible for making decisions about the PU presence and inform the reporting SUs. A DFC uses weighted majority voting among the reporting SUs, where weights are determined based on reputation. The DFC updates reputations of SUs based on confidence of an election. If the majority wins by a significant margin, the confidence of the election is high. In this case, SUs that belong to the majority get high reputations. We provide extensive simulations to validate our proposed model.