i need a program that prints out
1 2 3
1 2 3
1 2 3
if the input is 3
i've written this but doesnt work#include <stdio.h>
int main(void) {
int x;
int i;
int j;
int y = 1;
printf("Sayiyi giriniz: ");
scanf("%d", &x);
if(x < 2 || x > 40) {
return 0;
}
for(i = 0; i < x; i++) {
for(j = 0; j < x; j++) {
printf("%d", &y);
y++;
}
y = 1;
printf("\n");
}
return 0;
}
pls help...
pic to lure neckbeards
>Sayiyi giriniz
What third world shitspeak is this?
d-d-do my homework anon
>>59120688
shish kebab mate
greetings from arabia
>>59120688
Looks like dirty wanabe - euro, paedophile kebab speak.
Aka Turkish
>>59120720
correct
if input == 3:
print(”1 2 3\n"*3}
çek git
seems like /g/ changed a lot..
i'll give a shot to g/sqt/
>>59120865
Well, it's a direct interpretation of what he said. He should have specified that he wants it to do different things for different inputs. Or, better yet, do his own homework and actually learn something.
The anon who you replied to wasn't stupid, he's just making fun of op.
here ya go buddy boy#include <stdio.h>
int main(void) {
int x;
int i;
int j;
scanf("%d", &x);
printf("printing that shit:\n");
if (x < 2 || x > 40) return 0;
for (i = 0; i < x; i++) {
for (j = 0; j < x; j++) {
printf("%d ", j+1);
}
printf("\n");
}
return 0;
}
hopefully you feel silly now
The printf in your loop has &y instead of just y.
>>59120909
Please don't shit up other boards with your 101 class questions. Spend five minutes looking at your own code and trying to understand it. You will be infinitely better off for it.
>>59120940
fucking hell
i was wondering why it was printing things that resemble a memory adress... fuck me
this is C#, since you're a C smartass, you'll have no problems understanding thisstatic void Main(string[] args)
{
Console.Write("Digite um número: ");
string input = Console.ReadLine();
int size = int.Parse(input);
for(int x = 1; x <= size; x++)
{
for(int y = 1; y <= size; y++)
{
Console.Write($"{y} ");
}
Console.WriteLine();
}
Console.ReadKey();
}
>>59120940#include <stdio.h>
int main(void) {
int x;
int i;
int j;
int y = 1;
printf("Sayiyi giriniz: \n");
scanf("%d", &x);
printf("\n");
if(x < 2 || x > 40) {
return 0;
}
for(i = 0; i < x; i++) {
for(j = 0; j < x; j++) {
printf("%d", y);
printf(" ");
y++;
}
y = 1;
printf("\n");
}
return 0;
}
im proud of myself
thank you /g/entleman
int main(int argc, char** argv) {
if (argc > 1 && argv[0] == '3')
printf("1 2 3 1 2 3\n");
return 0;
}
>>59121061
I'm fucking stupid, s/argv\[0\]/argv[1]/
>>59120663
This program could be done in 3 lines of Python code by a literal retard after 10 minutes of an online course.
C is fucking garbage.
>>59121074
kek lets see you write that code
>>59121070
why didnt you escape the brackets in the next segment?
>>59120761
the best solution, obviously
pic related
>>59120752
You guys got universities?
>>59121229
not cool
>>59120761
>string * 3
Wtf does this work in java lol
>>59121176
the first part of the s/// is a regexp, and brackets have a special meaning in regexps. The second is not a regexp, it's just text for substitution. Only a $n (where n is a small integer) would have a special meaning there. So brackets need not be escaped
>>59121160
herec = 3
print((" ".join(map(str,range(1,c+1)))+"\n")*c)
>>59120663#include <stdio.h>
int main(void) {
int x;
scanf("%d", &x);
if(x == 3) {
printf("1 2 3\n1 2 3\n1 2 3\n");
}
return 0;
}
>>59121384
kek'd
>>59121384
>>59121405
samefag
#include <stdio.h>
int main(int argc, char *argv[]){
if(argc < 2)return 1;
if(argv[1][0] == '3')printf("1 2 3\n1 2 3\n1 2 3\n");
}
>>59121431
nop
>>59120663
fix thisprintf("%d", y);
>>59121352
Looks even more retarded than OPs code.
>>59121554
This is the correct answer though.
>>59120752
Lol turkey sucks
EASY LEL
var number = prompt("select letter");
if (number == 3) {
print "123";
print "123";
print "123";
}
>>59122036
Lol you never inplemented an input scanner and you could have printed it in one line. Stay in achool
>>59122036
Jk you did i am drunk
>>59121055
what if x = 2?
>>59122080
>you never inplemented an input scanner
You don't know what prompt does, do you
>>59122089
Kill yourself, you worthless piece of shit.
>>59122112
Correct response,
>>59122080
You don't know what irony is do you?
>>59122097
Then you do the for loop
>>59122139
Lol so upset
>>59122112
I said jk bro lol actually read the thread
just quit if you can't get this done
holy shit
If you can not solve that issue by your own you should just give up on programming and focus on making Kebabs, Ahmed.
>>59121301
can't multiply strings in java due to their immutable properties
>These are the kids that defend the piece of trash called C(ancer)
>>59124282
C is useful for some niche applications
not for general programming
>>59120663
what the fuck is this code?
why theif(x < 2 || x > 40)?
>>59120663
Scanner myScan = new Scanner(System.in);
System.out.print("Enter the number 3: ");
int three = myScan.nextInt();
System.out.println("Oh, you entered 3? Fuck you. " + 1 + " " + 2 + " " + 3);
>>59124929
suck my dick OP learn yourself
>>59120663
C stands for cancer. If you are determined to get cancer use a decent cancer like D.import std.stdio;
void main(){
write("Enter your loop size: ");
int n;
readf(" %s", &n);
writeln();
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++){
write(j, " ");
}
writeln();
}
writeln();
}
$ ldc2 test.d && ./test
Enter your loop size: 3
1 2 3
1 2 3
1 2 3
>>59121352
So readable, your superior code
>>59124999
nobody said it had to be readable
Spoonfeeding needs to be banned, all responses should have told OP to figure it out himself
>>59125341
C babbies need help
>>59120920
why do you need two for loops?
>>59126499
what's wrong with two for loops?
>>59121352
If you tried to commit shit like this I would bounce it back and then we'd all make fun of you during the 11:30 meeting.
>>59126725
O(N^2)
>>59120663
okay = input('enter 3')
if okay == 3 then
print('1 2 3')
print('1 2 3')
print('1 2 3')
end
>>59126725
Ignore me. I though the output was just one instance of "1 2 3" not multiple.
>>59126499
>>59126918
I guess he means that it would be better to construct the string first, which is linear, and then print it N times. The total runtime is going to be linear.
So what if you input 2?
>>59121352
>implying you can't do shitty oneliners in C#include <stdio.h>
int main() {
int c = 3;
for (int i=0;i<c*c;i++) printf("%d%c",i%c+1,i%c==c-1?'\n':' ');
}