+ 1

Shape A

How can I use arrays instead of the sentence on Line 7? https://code.sololearn.com/coxG3PhfjT8Q/?ref=app

29th Sep 2020, 3:56 PM
Alaa Z. Abu Zuhair
Alaa Z. Abu Zuhair - avatar
4 Antworten
+ 2
Alaa Z. Abu Zuhair nice try👍 but here are couple things you overlooked in your code :- 1) array index starts from 0 not 1 2) your else statement is inside the second *for* loop and will execute every time the if statement is false. { Just bring it outside} After applying all the fixes your code should look something like this👇 https://code.sololearn.com/cmGg1DpWYoTU/?ref=app
30th Sep 2020, 12:37 AM
Arsenic
Arsenic - avatar
+ 4
Fill all those values in an array and then for every iteration just check if that value is in the array of not.
29th Sep 2020, 4:03 PM
Arsenic
Arsenic - avatar
+ 1
Thanks Arsenic , I tried it but it didn't look right.. I wanted the letter A to appear on the output screen int main(){ int i,j; int A[7]={5,9,11,20,26,27,35}; for (i=1;i<=35;++i){ if(i>=14&&i<=18) goto one; for (j=1;j<=7;++j){ if(A[j]==i)goto one; else { cout<<" "; continue ; } } one: cout<<"*"; if (i==9||i==20||i==27)continue; if (i>=14&&i<=17)continue ; else cout<<"\n"; } return 0; }
29th Sep 2020, 7:49 PM
Alaa Z. Abu Zuhair
Alaa Z. Abu Zuhair - avatar
+ 1
Ok👍 Thanks , I am grateful to you Arsenic
30th Sep 2020, 1:53 AM
Alaa Z. Abu Zuhair
Alaa Z. Abu Zuhair - avatar