Thread: how to change this few code into C programming?(from C++)

  1. #1
    Registered User
    Join Date
    Feb 2015

    how to change this few code into C programming?(from C++)

    #include <cstdio>
    #include <vector>
    #include <algorithm>
    using namespace std;
    int main() {
      int T;
      scanf("%d", &T);
      while (T--) {
        int M, N, num[30000];
        scanf("%d%d", &M, &N);
        for (int i = 0; i < M; i++) {
          scanf("%d", &num[i]);
        vector<int> box;
        int done = 0, need = 0;
        while (N--) {
          int index;
          scanf("%d", &index);
          while (box.size() < index) {
            vector<int>::iterator it = lower_bound(box.begin(), box.end(), num[done]);
            box.insert(it, num[done++]);
          printf("%d\n", box[need++]);
        if (T) {
      return 0;

  2. #2
    Registered User
    Join Date
    May 2011
    Around 8.3 light-minutes from the Sun
    You mean this broken hybridization of C++/C code into just C? How about you tell us what you are trying to do and then make an attempt. Looking for answers to homework problems on the internet and then just dumping what you find on a forum in hopes that someone else will do work for you is not good practice nor will it get you help here. You should forget this code, start from scratch, beginning with defining your problem. Then read about the development process
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with small code change
    By Kryptonit in forum C Programming
    Replies: 4
    Last Post: 08-12-2009, 05:16 AM
  2. how to change it into one main() function code..
    By transgalactic2 in forum C Programming
    Replies: 10
    Last Post: 12-13-2008, 10:02 PM
  3. Will the upcoming C++ standard change how Programming languages are taught
    By indigo0086 in forum A Brief History of
    Replies: 5
    Last Post: 01-14-2008, 01:07 PM
  4. Programming - viable to change carreers?
    By 3DPhreak in forum A Brief History of
    Replies: 11
    Last Post: 06-07-2004, 04:07 PM
  5. Any tool to change c++ code into c code?
    By crliu in forum C++ Programming
    Replies: 3
    Last Post: 12-09-2002, 09:44 AM