private void CreateFIBQuestion(SectionBaseInfo info, Section section) { int minValue = 10; int maxValue = 100; if (info is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo; minValue = decimal.ToInt32(rangeInfo.MinValue); maxValue = decimal.ToInt32(rangeInfo.MaxValue); } if (section.QuestionCollection.Count == 0) { questionValueList.Clear(); } Random rand = new Random((int)DateTime.Now.Ticks); int valueA = 0, valueB = 0; int value = 0; while (true) { int sumCommonDivisor = 0; valueA = rand.Next(minValue, maxValue); valueB = rand.Next(minValue, maxValue); if (valueA < valueB) { value = valueA; } else if (valueA > valueB) { value = valueB; } else { continue; } for (int j2 = 1; j2 < value; j2++) { if (valueA % j2 == 0 && valueB % j2 == 0) { sumCommonDivisor++; } } if (sumCommonDivisor > 1) { break; } } string questionText = string.Format("写出{0}和{1}的所有公约数", valueA, valueB); FIBQuestion fibQuestion = new FIBQuestion(); fibQuestion.Content.Content = questionText; fibQuestion.Content.ContentType = ContentType.Text; section.QuestionCollection.Add(fibQuestion); if (valueA < valueB) { value = valueA; } else { value = valueB; } for (int j2 = 1; j2 <= value; j2++) { if (valueA % j2 == 0 && valueB % j2 == 0) { QuestionBlank blank = new QuestionBlank(); QuestionContent blankContent = new QuestionContent(); blankContent.Content = j2.ToString(); blankContent.ContentType = ContentType.Text; blank.ReferenceAnswerList.Add(blankContent); fibQuestion.QuestionBlankCollection.Add(blank); fibQuestion.Content.Content += blank.PlaceHolder; } } }
private void CreateFIBQuestion(SectionBaseInfo sectionInfo, Section section) { int minValue = 10; int maxValue = 100; if (sectionInfo is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = sectionInfo as SectionValueRangeInfo; minValue = decimal.ToInt32(rangeInfo.MinValue); maxValue = decimal.ToInt32(rangeInfo.MaxValue); } if (section.QuestionCollection.Count == 0) { this.questionValueList.Clear(); } Random rand = new Random((int)DateTime.Now.Ticks); int value = 0; int j = 0, k, iFlag1 = 0, iFlag2 = 0, j2 = 0, k2; int flag = 0; while (true) { flag = 0; for (int i2 = 0; i2 < maxValue; i2++) { value = rand.Next(minValue, maxValue); for (j = 2; j < value / 2 + 1; j++) { if (value % j == 0) { iFlag1 = 0; iFlag2 = 0; for (k = 2; k < j / 2 + 1; k++) { if (j % k == 0) { iFlag1 = 1; break; } } j2 = (int)(value / j); for (k2 = 2; k2 < j2 / 2 + 1; k2++) { if (j2 % k2 == 0) { iFlag2 = 1; break; } } if (iFlag1 == 0 && iFlag2 == 0) { flag = 1; break; } } } if (flag == 1) { break; } } if (Enumerable.Where <int>(questionValueList, (c => (c == value))).Count <int>() > 0) { Thread.Sleep(10); continue; } break; } questionValueList.Add(value); string questionText = string.Format("分解质因数 {0}=", value); FIBQuestion fibQuestion = new FIBQuestion(); fibQuestion.Content.Content = questionText; fibQuestion.Content.ContentType = ContentType.Text; section.QuestionCollection.Add(fibQuestion); QuestionBlank blank1 = new QuestionBlank(); QuestionContent blankContent1 = new QuestionContent(); blankContent1.Content = j.ToString(); blankContent1.ContentType = ContentType.Text; blank1.ReferenceAnswerList.Add(blankContent1); fibQuestion.QuestionBlankCollection.Add(blank1); QuestionBlank blank2 = new QuestionBlank(); QuestionContent blankContent2 = new QuestionContent(); blankContent2.Content = j2.ToString(); blankContent2.ContentType = ContentType.Text; blank2.ReferenceAnswerList.Add(blankContent2); fibQuestion.QuestionBlankCollection.Add(blank2); fibQuestion.Content.Content += string.Format("{0}×{1}", blank1.PlaceHolder, blank2.PlaceHolder); }
private void CreeateFIBQuestion(SectionBaseInfo info, Section section) { int minValue = 10; int maxValue = 100; if (info is SectionValueRangeInfo) { SectionValueRangeInfo rangeInfo = info as SectionValueRangeInfo; minValue = decimal.ToInt32(rangeInfo.MinValue); maxValue = decimal.ToInt32(rangeInfo.MaxValue); } List <int> questionValueList = new List <int>(); Random rand = new Random((int)DateTime.Now.Ticks); int valueA = 0, valueB = 0, valueC = 0; int value = 0; while (true) { int j2 = 0; valueA = rand.Next(minValue, maxValue); valueB = rand.Next(minValue, maxValue); if (valueA > valueB) { value = valueA; } else if (valueA < valueB) { value = valueB; } else { continue; } j2 = value; while (true) { if (j2 % valueA == 0 && j2 % valueB == 0) { valueC = j2; break; } j2++; } break; } string questionText = string.Format("写出{0}和{1}的最小公倍数", valueA, valueB); FIBQuestion fibQuestion = new FIBQuestion(); fibQuestion.Content.Content = questionText; fibQuestion.Content.ContentType = ContentType.Text; section.QuestionCollection.Add(fibQuestion); QuestionBlank blank = new QuestionBlank(); QuestionContent blankContent = new QuestionContent(); blankContent.Content = valueC.ToString(); blankContent.ContentType = ContentType.Text; blank.ReferenceAnswerList.Add(blankContent); fibQuestion.QuestionBlankCollection.Add(blank); fibQuestion.Content.Content += blank.PlaceHolder; }