0分错一堆,求助!!!
查看原帖
0分错一堆,求助!!!
615164
Hanson666楼主2022/3/5 20:38
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int a[1000];int q;cin>>q;
	for(int w=0;a<100;a++){
		if(q%2==1){
			q=q*3+1;
			a[w]=q*3+1;
		}
		else{
			
			q=q/2;
			a[w]=q/2;
		}
	}
	for(int w=100;w>=0;w--){
		cout<<a[w]<<" "; 
	}
	return 0;	
}

/tmp/compiler_cc_p9e67/src:17:18: 错误:程序中有游离的‘\357’ 17 | cout<<a[w]<<" "; | ^ /tmp/compiler_cc_p9e67/src:17:19: 错误:程序中有游离的‘\274’ 17 | cout<<a[w]<<" "; | ^ /tmp/compiler_cc_p9e67/src:17:20: 错误:程序中有游离的‘\233’ 17 | cout<<a[w]<<" "; | ^ /tmp/compiler_cc_p9e67/src: 在函数‘int main()’中: /tmp/compiler_cc_p9e67/src:6:16: 错误:ISO C++ 不允许比较指针和整数的值 [-fpermissive] 6 | for(int w=0;a<100;a++){ | ^~~ /tmp/compiler_cc_p9e67/src:6:21: 错误:自增操作数必须是左值 6 | for(int w=0;a<100;a++){ | ^~ /tmp/compiler_cc_p9e67/src:16:6: 错误:‘w’在此作用域中尚未声明 16 | for(w=100;w>=0;w--){ | ^

2022/3/5 20:38
加载中...