473,657 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is wrong!

Hi all,
I wrote the code to get the following output:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3
but,the output received from the code is different.
there is some mistake and I got confusion on.if you
know some better advice and correction to my code,
please show it.

tanx a lot!

the code wrote by me is as below:

#include<stdio. h>

int main(){
int a[10][10];
int i,j,k,temp;

printf("input the integer\n");
for(i=0;i<10;i+ +)
scanf("%d",&a[0][i]);
printf("put the integer 9times\n");
for(i=0;i<9;i++ ){
scanf("%d",&tem p);

a[i+1][temp-1] = a[i][0];

for(j=0;j<temp-1;j++)
a[i+1][j] = a[i][j+1];
for(j=temp;j<10 ;j++)
a[i+1][j] = a[i][j];

}
for(i=0;i<10;i+ +){
for(j=0;j<10;j+ +){
printf("%d ",a[i][j]);
}
printf("\n");
return 0;
}
}

--
John

Nov 14 '05 #1
10 1162

"John" <gh*****@fsmail .net> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
Hi all,
I wrote the code to get the following output:
1 2 3 4 5 6 7 8 9 10
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10
2 1 3 4 5 6 7 8 9 10
1 3 2 4 5 6 7 8 9 10
3 2 4 1 5 6 7 8 9 10
2 4 1 5 3 6 7 8 9 10
4 1 5 3 6 2 7 8 9 10
1 5 3 6 2 7 4 8 9 10
5 3 6 2 7 4 8 1 9 10
3 6 2 7 4 8 1 9 5 10
6 2 7 4 8 1 9 5 10 3
but,the output received from the code is different.
there is some mistake and I got confusion on.if you
know some better advice and correction to my code,
please show it.


Please describe exactly what the program is supposed to
do. I won't try to figure out what the 'pattern' is
supposed to be.

The way you've phrased it, my solution would be to
simply 'hard code' those lines and output them

e.g.:

puts("1 2 3 4 5 6 7 8 9 10");

etc.

(but I doubt that's what's wanted).

Also please learn to indent your code.

-Mike

Nov 14 '05 #2
Dear Mike,

I try to declare a two dimensional array with a size 10 by 10 at
first.after that I am
going to read the integers into a[0][0] to a[0]]9] .after that,I am
going to repeat the
insertion specified by an integer sequence about 9 times, and store the
results from
a[1] to a[9].
at the final,I try to print the array same as I pointed to my first
post as an out put.

thanks

Nov 14 '05 #3
On 8 Jan 2005 07:20:31 -0800, "John" <gh*****@fsmail .net> wrote:

One mistake I notice is that the return statement is inside
the loop instead of following it:
for(i=0;i<10;i ++){
for(j=0;j<10;j ++){
printf("%d ",a[i][j]);
}
printf("\n");
return 0;
}


Nick.

Nov 14 '05 #4
"Mike Wahler" <mk******@mkwah ler.net> writes:
[snip]
Also please learn to indent your code.

-Mike


The OP probably did indent his code. There's a serious bug (several,
actually) in the new groups.google.c om posting interface.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #5

"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
"Mike Wahler" <mk******@mkwah ler.net> writes:
[snip]
Also please learn to indent your code.

-Mike


The OP probably did indent his code. There's a serious bug (several,
actually) in the new groups.google.c om posting interface.


This is why we always advise folks not to post code
with tabs -- convert them to spaces first. Or is
google mangling those too?

-Mike
Nov 14 '05 #6
"Mike Wahler" <mk******@mkwah ler.net> writes:
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
"Mike Wahler" <mk******@mkwah ler.net> writes:
[snip]
> Also please learn to indent your code.
>
> -Mike


The OP probably did indent his code. There's a serious bug (several,
actually) in the new groups.google.c om posting interface.


This is why we always advise folks not to post code
with tabs -- convert them to spaces first. Or is
google mangling those too?


Google is indiscriminantl y deleting leading whitespace on most lines,
both spaces and tabs. I've seen some indentation that it doesn't
delete, but I have no clue why. (I imagine this is even worse for the
Python groups.)

It also deletes multiple empty lines in some cases, and its attempt to
mask e-mail addresses mangles anything containing "@" characters
(which is a serious problem for TeX source code and the folks in
rec.games.rogue like.developmen t).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #7
Keith Thompson <ks***@mib.or g> scribbled the following:
"Mike Wahler" <mk******@mkwah ler.net> writes:
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
"Mike Wahler" <mk******@mkwah ler.net> writes:
[snip]
> Also please learn to indent your code.
>
> -Mike

The OP probably did indent his code. There's a serious bug (several,
actually) in the new groups.google.c om posting interface.
This is why we always advise folks not to post code
with tabs -- convert them to spaces first. Or is
google mangling those too?

Google is indiscriminantl y deleting leading whitespace on most lines,
both spaces and tabs. I've seen some indentation that it doesn't
delete, but I have no clue why. (I imagine this is even worse for the
Python groups.) It also deletes multiple empty lines in some cases, and its attempt to
mask e-mail addresses mangles anything containing "@" characters
(which is a serious problem for TeX source code and the folks in
rec.games.rogue like.developmen t).


Seems like Google is hell-bent on destroying Usenet.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Outside of a dog, a book is a man's best friend. Inside a dog, it's too dark
to read anyway."
- Groucho Marx
Nov 14 '05 #8
"Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message
news:cr******** **@oravannahka. helsinki.fi...
Keith Thompson <ks***@mib.or g> scribbled the following:
"Mike Wahler" <mk******@mkwah ler.net> writes:
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
"Mike Wahler" <mk******@mkwah ler.net> writes:
[snip]
> Also please learn to indent your code.
>
> -Mike

The OP probably did indent his code. There's a serious bug (several,
actually) in the new groups.google.c om posting interface.

This is why we always advise folks not to post code
with tabs -- convert them to spaces first. Or is
google mangling those too?

Google is indiscriminantl y deleting leading whitespace on most lines,
both spaces and tabs. I've seen some indentation that it doesn't
delete, but I have no clue why. (I imagine this is even worse for the
Python groups.)

It also deletes multiple empty lines in some cases, and its attempt to
mask e-mail addresses mangles anything containing "@" characters
(which is a serious problem for TeX source code and the folks in
rec.games.rogue like.developmen t).


Seems like Google is hell-bent on destroying Usenet.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\


The easiest way to deal with Google is to prepend a "|" to every line of
code. It is annoying to have to get rid of these if you plan on
copying/pasting/compiling the code, but its easier to read with '|' and
proper indentation than without any indentation.
Nov 14 '05 #9
"Richards Noah \(IFR LIT MET\)" <No***********@ infineon.com> writes:
"Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message

[...]
Seems like Google is hell-bent on destroying Usenet.


The easiest way to deal with Google is to prepend a "|" to every line of
code. It is annoying to have to get rid of these if you plan on
copying/pasting/compiling the code, but its easier to read with '|' and
proper indentation than without any indentation.


The easist way to deal with Google is to post through
groups.google.c a, which still uses the old (working) interface.
There may be other local groups.google.* sites that will also work.

I started a separate thread on these problems, subject
"groups.google. com indentation bugs [semi-OT]". I suggest carrying on
this discussion there.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
14702
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
5
2826
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
72
5832
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for example, between a C/C++ programmers with a few weeks of experience and a C/C++ programmer with years of experience. You don't really need to understand the subtle details or use the obscure features of either language
121
10024
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
28
3262
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr(); fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
56
4315
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on C. wat type of questions should be expected? Which part of C language do the staff give more concern? The interviewers have just mentioned that .. i will have interview on C. Also can anyone can help me with sites where i can go thru sample
46
4197
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do believe MSFT should do to improve C#, however. I know that in the "Whidbey" release of VS.NET currently
13
5035
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
2116
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
3
2139
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when Record (i) is shown and modified, the change will come to Record (i+1). Can anyone provide suggestion? thanks.
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.