有没有办法让C++检测到当一个值以某个数字结尾时它会执行 if 语句?



这是我第一次在这里发帖!我知道我的问题听起来不太正确,但我对编程真的很陌生。在我的程序中,我需要如果用户输入一个数字(1 <= 365),那么程序将告诉它是哪一天。然后我想出了一个解决方案,但我不知道c++是否能做到。例如,如果A/7= 3.6, B/7= 2.1或C/7=2.9,那么它将读取最后一个小数并每次执行不同的if函数(例如,如果它以。6结尾,程序就会说今天是星期四,而。9则是星期天,以此类推)。我希望这有点道理。由于

#include <cstdio>
main()
{
float n, D; 
printf("Enter the number of the day n:n");
scanf("%f", &n);
D = n/7
if (D = )/*here I'm trying that if D ends with some number it'll do this*/
{ 
printf("It's Monday")
}
}

将10乘以'%'得到余数如何?

相关内容

最新更新