我有一个问题,我试着写一个程序来显示从1到22的整个总和,然后,做2个while循环.第一个应该执行用户给出的某些数字的总和,例如:输入10,30和40然后当输入0时,程序将前三个数字相加.不幸的是,第一个while循环不起作用.它直接进入最后一个while循环,它应该键入一个十进制数字,如(10.20 30.50 40.55),再次输入0后,它将这些数字相加,并将每个条目加上和乘以1.19.到目前为止,最后一个循环工作正常,不幸的是第二个循环没有,如果我移动printf和scanf,它让我写,但只是开始写,没有停止我写的数字.先感谢您!
这是代码:
#include <stdio.h>
int main()
{
int sum = 0;
int a;
int b;
double i;
double sum1 = 0;
for (a= 0; a <= 22; a++) {
sum = sum + a;
printf("the sum from 1 till 22 : %i\n ", sum);
}
while (b != 0) {
printf("type a number:");
scanf("%i", &b);
sum += b;
printf("%i\n", b);
}
printf("the sum is : %i\n", sum);
while(i !=0) {
printf ("Type a decimal number:");
scanf ("%lf",&i);
sum1 …Run Code Online (Sandbox Code Playgroud) 我用地图存储了一些键值,然后我需要按值对它们进行排序,我很想使用它:
#include <iostream>
#include <map>
#include <string>
int main ()
{
std::map<std::string, int> map1;
std::multimap<int, std::string> multimap2;
map1.insert ( std::pair<std::string, int>( "one", 4) );
map1.insert ( std::pair<std::string, int>( "two", 2) );
map1.insert ( std::pair<std::string, int>( "three", 2) );
map1.insert ( std::pair<std::string, int>( "four", 1) );
for (auto it = map1.begin(); it != map1.end(); ){
multimap2.insert(std::pair<int, std::string>( it->second, it->first));
map1.erase(it++);
}
for (auto it = multimap2.rbegin(); it != multimap2.rend(); ++it)
std::cout << it->first << " --- " << it->second << '\n'; …Run Code Online (Sandbox Code Playgroud) 我的代码在所有H2列中粘贴相同的公式.我没有在代码中的任何地方看到它应该这样做.
Worksheets("sheet1").Activate
Range("F2").Activate
Do Until IsEmpty(ActiveCell)
If ActiveCell.Value <> "" Then
Pickle = ActiveCell.Address
ActiveCell.Offset(0, 2).Select
ActiveCell.Value = "=IF(" + Pickle + " <TODAY(),""Send Reminder"",""Do not Send Reminder"") "
ActiveCell.Offset(0, -2).Select
End If
ActiveCell.Offset(1, 0).Select
Loop
Run Code Online (Sandbox Code Playgroud)