本文介绍了我得到错误“错误:预期表达之前'! ='令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我是c编程的初学者。 在下面的程序中检查一年是否是闰年,我在编译期间不断收到上述错误 我的条件逻辑: 如果年份可被4整除 1.如果年份不能被100整除则是闰年。它不是闰年) 2.如果年份可以被100整除,那么它必须可以被400整除。 有人可以检查逻辑/语法错误并向我解释一下吗? 非常感谢。 我尝试过: #include< stdio.h> int main() { int y; printf(输入年份); scanf(%d,& y); if(y%4 == 0) { if(y%100 =!= 0) printf(闰年 ); else printf(不是闰年。);} 其他 { if(y%100 == 0) { if(y%400 == 0) printf(闰年); else printf(不是闰年);}} 返回0;} 解决方案 因为1.和2.是自相矛盾的。 通过编程,你需要格外小心一切,嵌套,结构 I'm a beginner in c programming.In the following program to check whether or not a year is a leap year, I keep getting the above mentioned error during compilationmy logic for the conditions:if the year is divisible by 41. if the year is not divisible by 100 it is a leap year.(otherwise its not a leap year)2. if the year is divisible by 100,to be a leap year it must also be divisible by 400.Could someone please check the logic/syntax errors and explain them to me?Much obliged thanks.What I have tried:#include <stdio.h>int main(){int y;printf("enter the year");scanf("%d",&y); if(y%4==0){ if(y%100=!=0) printf("Leap Year"); else printf("Not a Leap year.");}else{ if(y%100==0) { if(y%400==0) printf("Leap year");else printf("Not a Leap Year");}} return 0;} 解决方案As is 1. and 2. are self contradictory.With programming, you need to be extra careful about position of everything, nesting, structure. 这篇关于我得到错误“错误:预期表达之前'! ='令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-21 02:10