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",&temp);
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 10 1149
"John" <gh*****@fsmail.net> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.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
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
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.
"Mike Wahler" <mk******@mkwahler.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.com posting interface.
--
Keith Thompson (The_Other_Keith) 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.
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org... "Mike Wahler" <mk******@mkwahler.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.com 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
"Mike Wahler" <mk******@mkwahler.net> writes: "Keith Thompson" <ks***@mib.org> wrote in message news:ln************@nuthaus.mib.org... "Mike Wahler" <mk******@mkwahler.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.com 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 indiscriminantly 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.roguelike.development).
--
Keith Thompson (The_Other_Keith) 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.
Keith Thompson <ks***@mib.org> scribbled the following: "Mike Wahler" <mk******@mkwahler.net> writes: "Keith Thompson" <ks***@mib.org> wrote in message news:ln************@nuthaus.mib.org... "Mike Wahler" <mk******@mkwahler.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.com 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 indiscriminantly 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.roguelike.development).
Seems like Google is hell-bent on destroying Usenet.
--
/-- Joona Palaste (pa*****@cc.helsinki.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
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:cr**********@oravannahka.helsinki.fi... Keith Thompson <ks***@mib.org> scribbled the following: "Mike Wahler" <mk******@mkwahler.net> writes: "Keith Thompson" <ks***@mib.org> wrote in message news:ln************@nuthaus.mib.org... "Mike Wahler" <mk******@mkwahler.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.com 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 indiscriminantly 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.roguelike.development).
Seems like Google is hell-bent on destroying Usenet.
-- /-- Joona Palaste (pa*****@cc.helsinki.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.
"Richards Noah \(IFR LIT MET\)" <No***********@infineon.com> writes: "Joona I Palaste" <pa*****@cc.helsinki.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.ca, 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_Keith) 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.
Keith Thompson <ks***@mib.org> writes:
[...] The easist way to deal with Google is to post through groups.google.ca, 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.
But "Old Wolf" points out an apparent problem with groups.google.ca in
that thread. (It's a pity I can't redirect followups to a thread.)
--
Keith Thompson (The_Other_Keith) 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: titan0111 |
last post by:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<fstream>
using namespace std;
class snowfall
{
private:
int ft;
|
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...
|
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...
|
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();...
|
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...
|
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...
|
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
|
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=
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
| |