题目是统计直角的数目p491 点击跳转

#include <bits/stdc++.h>
using namespace std;
int main()
{
long int geshu,s,j,i;
cin>>geshu;
int n[geshu];
for(i=0;i<geshu;i++)
{
    cin>>n[i];
}
for(j=0;j<geshu;j++)
{
    if(n[j]==90)
    {
        s+=1;
    }
}
cout<<s;
return 0;
}

dev试了似乎可以,

上了oj就一直WA

求大佬解答~~~~~

2 条评论

  • @ 2024-10-27 11:02:20

    ok了, 终于AC了;

    🤡 1
    • @ 2024-10-27 10:22:51

      我猜应是变量(记得赋值为0!!!)... 如:

      ``#include <bits/stdc++.h>
      using namespace std;
      typedef long long ll;
      inline int read(){
      	int s=0,w=1;
      	char ch=getchar();
      	while(ch<'0'||ch>'9'){
      		if(ch=='-') w=-1;
      		ch=getchar();
      	}
      	while(ch>='0'&&ch<='9')
      		s=s*10+ch-'0',ch=getchar();
      	return s*w;
      }
      ll n,x,ans=0,i;
      int main(){
      	n=read();
      	for(i=1;i<=n;++i){
      		x=read();
      		if(x==90) ans++;
      	}
      	cout<<ans<<"\n";
      	return 0;
      }
      
      👍 1
      • 1