It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need this translated into MIPS Assembly (to work on Mars Assembler)
void mm ( double x[][], double y[][], double z[][], int n)
{
int i,j;
for (i=0; i !=n; i++)
for (j=0; j !=n; j++)
z[i][j] = 0.0;
for (k=0; k !=n; k++)
z[i][j] = z[i][j] + x[i][k] * y[k][j];
}
This seems a little bit like a "Do My Homework" question, but i'll give you a hint.
Passing the -S switch to gcc will cause it to emit assembly code. Note, this code may need to be tweaked for the mars assembler.
Good luck!
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
can anyone supply a complicate example using loop invariant example such as sum(int n) is so trivial that it can not show the power of loop invariant. I want a example that is not that obivious, and we can use method like loop invariant to solve it.
The Wikipedia example is quite good:
for (int i = 0; i < n; i++) {
x = y + z;
a[i] = 6 * i + x * x;
}
Two invariant can be moved (y + z and x * x). The advantage of this example is that after LICM has been applied, you can apply other optimizations on the code to have something very easy.
There are plenty on papers/slides/courses about that, you sure can find a satisfying example.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm learning c and I can't figure out the problem with this code:
#include <stdio.h>
int main(){
int i = 0;
while(i > 10){
printf("hello");
i++;
}
getch();
return 0;
}
I don't get any errors and have tried running it on codeblocks and wxdev c++. So is there something I'm doing wrong. Thanks.
You set
i = 0;
and then test
i > 10
which is always false.
You might want
while (i < 10)
instead.
I is not greater than 10 so it doesnt meet the requirement to enter the while loop
while(i > 10){
...but i is 0 so it's false and skips.
You probably meant to instead write;
while(i < 10) {
Reason: i is not greater than 10.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Original page: http://acm.whu.edu.cn/learn/problem/detail?problem_id=1036
This should be a simple Dynamic Programming problem. I figured out the solution to be the following:
int main(void)
{
double d[501];
int i;
d[0] = d[1] = 1.;
d[2] = 2.;
for(i = 3; i<=500; i++)
d[i] = d[i-1] + d[i-2] + d[i-3];
int n;
while(scanf("%d", &n) == 1) {
if(n == 0) return 0;
printf("%.0lf\n", d[n]);
}
return 0;
}
But Wrong Answer reported after submission. I really don't know why.
double is not enough for the precision
you should use high-precision to solve it
Decimal point maybe. printf("%.0lf\n", 1.0); will print 1.0 but system may wait for 1.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am looking for a forward slicing tool for the C language. When I searched in Google, I didn't find any result.
I would have liked to access the Wisconsin Program-Slicing Tool Version 1.1, but this tool wasn't distributed. Could any other tool provide the functionality of forward slicing C programs?
The open-source static analysis platform Frama-C has a slicing plug-in with impact analysis functionality.
The OP suggests an example where the impact of the initialization sum = 0; is being computed. The example is like this:
void main() {
int i = 1; int sum = 0;
while (i<11) {
sum = add(sum, i);
i = add(i, 1);
}
printf("sum = %d\n", sum);
printf("i = %d\n", i);
}
static int add(int a, int b)
{
return(a+b);
}
The command-line to use is:
frama-c-gui -val t.c
The check-mark in the left-hand side column tells the user that there are selected statements in function add, too. In the bottom right corner, the analyzer points out a few minor issues with this example from an academic article.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Tips on how to do multiplication table in c??
ummm... two (nested) loops?
This should work. Really.
printf("2x1=2");
printf("2x2=4");
printf("2x3=6");
printf("2x4=8");
...
You should read books this is very basic things of programming you must clear this things yourself.
I personally recommend you not just to post here and get answer
Try reading and try developing by yourself before you post it overhere.
http://www.cprogramming.com/tutorial/c/lesson3.html
int main () {
int n = 10;
int i, j;
// Print row labels
for (i=1; i<=n; i++) {
for (j=1; j<=n; j++) {
//printf("\t%d",i*j);
//Do something here to get it working.. :-)
}
printf("\n");
}
}
You have to use 2 nested loops and if you want to make it more organized, use a two-dimensional array.